| | |
| | | |
| | | <!--详情信息(自定义查询)--> |
| | | <select id="getLandInfo" resultType="org.springblade.modules.lang.vo.LandVO"> |
| | | select user_id, |
| | | land_name, |
| | | land_type, |
| | | land_area, |
| | | ST_ASTEXT(land_range) as landRange, |
| | | type, |
| | | land_unit, |
| | | url |
| | | from sys_land |
| | | select l.user_id, |
| | | l.land_name, |
| | | l.land_type, |
| | | l.land_area, |
| | | ST_ASTEXT(l.land_range) as landRange, |
| | | l.type, |
| | | l.land_unit, |
| | | l.url, |
| | | bdb.dict_value dica |
| | | from sys_land l |
| | | LEFT JOIN blade_dict_biz bdb ON bdb.dict_key =l.land_unit |
| | | where 1 = 1 |
| | | and is_deleted = 0 |
| | | and id = #{land.id} |
| | | and l.is_deleted = 0 |
| | | AND bdb.code = 'landunit' |
| | | and l.id = #{land.id} |
| | | </select> |
| | | |
| | | <!--自定义地块数据--> |
| | |
| | | } |
| | | |
| | | /** |
| | | * 自定义详情 |
| | | */ |
| | | @GetMapping("/details") |
| | | public R<SoldrVO> details(SoldrVO soldr) { |
| | | SoldrVO detail = soldrService.getSoldrInfo(soldr); |
| | | return R.data(detail); |
| | | } |
| | | /** |
| | | * 分页 已出库存数量记录表 |
| | | */ |
| | | @GetMapping("/list") |
| | |
| | | @Param("type") String type); |
| | | |
| | | void cancelDel(Long id); |
| | | |
| | | SoldrVO getSoldrInfo(@Param("soldr") SoldrVO soldr); |
| | | |
| | | Boolean delLogic(Long id); |
| | | } |
| | |
| | | from sys_soldr |
| | | where id = #{id} |
| | | </delete> |
| | | <update id="delLogic"> |
| | | UPDATE sys_soldr SET is_deleted = 1 WHERE sid =#{id} |
| | | </update> |
| | | |
| | | <!--已出农资列表--> |
| | | <select id="selectSol" resultType="org.springblade.modules.soldr.vo.SoldrVO"> |
| | |
| | | SELECT * FROM sys_soldr WHERE |
| | | stock_id1 = #{stockId1} and specs1=#{specs1} and specs_val1=#{specsVal1} and specs_val2=#{specsVal2} and sid=#{sid} and type=#{type} and is_deleted=0 |
| | | </select> |
| | | <select id="getSoldrInfo" resultType="org.springblade.modules.soldr.vo.SoldrVO"> |
| | | SELECT st.id,st.stock_id1, |
| | | st.specs1, |
| | | st.sid, |
| | | st.amount1 AS amount1, |
| | | stf.factory_name AS factoryName, |
| | | a.dict_value AS stype, |
| | | d.dict_value AS dic1, |
| | | c.dict_value AS dic2, |
| | | stf.agricultural_name as agrname, |
| | | st.dept_id |
| | | FROM sys_soldr st |
| | | LEFT JOIN sys_stockfactory stf ON stf.id = st.stock_id1 |
| | | LEFT JOIN (SELECT dict_key, dict_value |
| | | FROM blade_dict_biz |
| | | WHERE CODE = 'stockSpecs1' AND is_deleted = 0 <if test="soldr.codes!=null and soldr.codes != ''"> |
| | | AND blade_dict_biz.tenant_id = #{soldr.codes} |
| | | </if>) d ON d.dict_key = st.specs_val1 |
| | | LEFT JOIN (SELECT dict_key, dict_value |
| | | FROM blade_dict_biz |
| | | WHERE CODE = 'stockSpecs2' AND is_deleted = 0 <if test="soldr.codes!=null and soldr.codes != ''"> |
| | | AND blade_dict_biz.tenant_id = #{soldr.codes} |
| | | </if>) c ON c.dict_key = st.specs_val2 |
| | | LEFT JOIN ( SELECT dict_key, dict_value FROM blade_dict_biz WHERE CODE = 'stockType' AND is_deleted = 0 <if |
| | | test="soldr.codes!=null and soldr.codes != ''"> |
| | | AND blade_dict_biz.tenant_id = #{soldr.codes} |
| | | </if>) a ON |
| | | a.dict_key = stf.type |
| | | WHERE st.is_deleted = 0 |
| | | <if test="soldr.id!=null and soldr.id != ''"> |
| | | AND st.id = #{soldr.id} |
| | | </if> |
| | | <if test="soldr.stype!=null and soldr.stype != ''"> |
| | | and stf.type = #{soldr.stype} |
| | | </if> |
| | | <if test="soldr.stockId1!=null and soldr.stockId1 != ''"> |
| | | and st.stock_id1 = #{soldr.stockId1} |
| | | </if> |
| | | <if test="soldr.deptId != null and soldr.deptId !=''"> |
| | | AND st.dept_id = #{soldr.deptId} |
| | | </if> |
| | | </select> |
| | | |
| | | <update id="cancelDel"> |
| | | UPDATE sys_soldr SET is_deleted = 0 WHERE id = #{id} |
| | |
| | | * @param id |
| | | */ |
| | | void cancelDel(Long id); |
| | | |
| | | SoldrVO getSoldrInfo(SoldrVO soldr); |
| | | |
| | | Boolean delLogic(Long id); |
| | | } |
| | |
| | | baseMapper.cancelDel(id); |
| | | } |
| | | |
| | | @Override |
| | | public SoldrVO getSoldrInfo(SoldrVO soldr) { |
| | | return baseMapper.getSoldrInfo(soldr); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean delLogic(Long id) { |
| | | return baseMapper.delLogic(id); |
| | | } |
| | | |
| | | } |
| | |
| | | //对库存表操作 |
| | | //判断stockType1 0出库 1入库 |
| | | if (stockRecord.getStockType1() == 0) { |
| | | //根据stockRecord中的srId找到对应的已出库记录表的对应数据 |
| | | Soldrecord soldrecord = soldrecordService.getById(stockRecord.getSrId()); |
| | | //根据stockId、specs1、specs_val1、specs_val2、sid、type找到soldr表中对应的数据 |
| | | Soldr soldr = soldrService.getByServalParam(soldrecord.getStockId1(),soldrecord.getSpecs1(),soldrecord.getSpecsVal1(),soldrecord.getSpecsVal2(),soldrecord.getSid(),soldrecord.getType()); |
| | | if (soldr.getAmount1()<soldrecord.getAmount1()){//已出库农资的数量比出库记录表中的数量少,不能回退 |
| | | throw new org.springblade.core.log.exception.ServiceException(StringUtil.format("当前库存不足!")); |
| | | }else { |
| | | //0出库 删除记录后原库存添加 |
| | | stock.setAmount(stock.getAmount() + stockRecord.getAmount1()); |
| | | //对已出库表操作 soldr出库数量记录表已出库农资减少 soldrecord出库记录表的数据也要删除 |
| | | //对soldrecord表逻辑删除 |
| | | soldrecordService.deleteLogic(Func.toLongList(soldrecord.getId().toString())); |
| | | Integer sub = soldr.getAmount1() - soldrecord.getAmount1(); |
| | | if (sub <= 0) { |
| | | soldrService.dels(soldr.getId()); |
| | | } else { |
| | | if (stockRecord.getType1().equals("4")){ //如果是农资退回 |
| | | Soldrecord soldrecord = soldrecordService.getById(stockRecord.getSrId()); |
| | | Soldr soldr = soldrService.getByServalParam(soldrecord.getStockId1(), soldrecord.getSpecs1(), soldrecord.getSpecsVal1(), soldrecord.getSpecsVal2(), soldrecord.getSid(), "0"); |
| | | if (stock.getAmount()<stockRecord.getAmount1()){//库存数量比出入库记录表数量少 没那么多库存补 |
| | | throw new org.springblade.core.log.exception.ServiceException(StringUtil.format("当前库存不足!")); |
| | | }else { |
| | | stock.setAmount(stock.getAmount() - stockRecord.getAmount1()); |
| | | soldrecordService.deleteLogic(Func.toLongList(soldrecord.getId().toString())); |
| | | Integer sub = soldr.getAmount1() + stockRecord.getAmount1(); |
| | | soldr.setAmount1(sub); |
| | | soldrService.updateById(soldr); |
| | | } |
| | | }else {//其他出库类型 |
| | | stock.setAmount(stock.getAmount() + stockRecord.getAmount1()); |
| | | } |
| | | } |
| | | else { |
| | | //1 入库 删除记录后原库存减少 |
| | | if (stockRecord.getAmount1() > stock.getAmount()) { //出入库记录表中的数量比库存的数量多不让回退 |
| | | throw new org.springblade.core.log.exception.ServiceException(StringUtil.format("当前库存不足!")); |
| | | throw new org.springblade.core.log.exception.ServiceException(StringUtil.format("当前农资库存不足!")); |
| | | } else { |
| | | stock.setAmount(stock.getAmount() - stockRecord.getAmount1()); |
| | | } |
| | |
| | | stf.factory_name AS factoryName, |
| | | d.dict_value AS dic1, |
| | | c.dict_value AS dic2, |
| | | a.name as czr, |
| | | a.real_name as czr, |
| | | f.agricultural_name as agrname |
| | | FROM `sys_stockrecord` st |
| | | LEFT JOIN sys_stockfactory stf |
| | |
| | | AND is_deleted = 0 <if test="stockrecord.codes!=null and stockrecord.codes != ''"> |
| | | AND blade_dict_biz.tenant_id = #{stockrecord.codes} |
| | | </if>) c ON c.dict_key = st.specs_val2 |
| | | LEFT JOIN (SELECT name, id FROM blade_user WHERE is_deleted = 0) a ON a.id = st.create_user |
| | | LEFT JOIN (SELECT real_name, id FROM blade_user WHERE is_deleted = 0) a ON a.id = st.create_user |
| | | LEFT JOIN ( SELECT agricultural_name,id FROM sys_stockfactory WHERE is_deleted = 0 ) f ON f.id = st.stock_id1 |
| | | WHERE st.is_deleted = 0 |
| | | <if test="stockrecord.agrname!=null and stockrecord.agrname != ''"> |