| | |
| | | import com.consum.base.core.utils.MapUtils; |
| | | import com.consum.base.core.utils.MapperUtil; |
| | | import com.consum.base.core.utils.PageUtil; |
| | | import com.consum.base.pojo.excel.InventoryExcelTemplate; |
| | | import com.consum.base.pojo.query.LWhFormInventoryQry; |
| | | import com.consum.base.pojo.request.FormInventoryParam; |
| | | import com.consum.base.pojo.request.LWhFormInventoryParam; |
| | |
| | | import com.consum.model.po.FinSysTenant; |
| | | import com.consum.model.po.FinSysTenantUser; |
| | | import com.consum.model.po.LWhFormInventory; |
| | | import com.iplatform.model.po.S_user_core; |
| | | import com.walker.db.page.GenericPager; |
| | | import com.walker.infrastructure.utils.DateUtils; |
| | | import com.walker.infrastructure.utils.StringUtils; |
| | |
| | | import org.apache.commons.compress.utils.Lists; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class LWhFormInventoryServiceImpl extends BaseServiceImpl { |
| | | public class LWhFormInventoryServiceImpl extends BaseServiceImpl implements LWhFormInventoryService { |
| | | |
| | | @Autowired |
| | | private CodeGeneratorService codeGeneratorService; |
| | | @Autowired |
| | | private BaseWarehouseServiceImpl baseWarehouseService; |
| | | @Autowired |
| | | private FinSysTenantUserServiceImpl finSysTenantUserService; |
| | | private BaseWarehouseService baseWarehouseService; |
| | | @Autowired |
| | | private LWhFormInventoryGoodsServiceImpl inventoryGoodsService; |
| | | @Autowired |
| | | private BaseGoodsTemplateServiceImpl baseGoodsTemplateService; |
| | | @Autowired |
| | | private LWhGoodsService lWhGoodsService; |
| | | @Autowired |
| | | private FinSysTenantServiceImpl finSysTenantService; |
| | | @Autowired |
| | | @Lazy |
| | | private LWhFormInventoryCoreService lWhFormInventoryCoreService; |
| | | |
| | | |
| | | private static final String QUERY_LIST = "select * from l_wh_form_inventory where 1=1 "; |
| | |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/10/31 |
| | | */ |
| | | @Override |
| | | public int add(FormInventoryParam param, FinSysTenantUser currentUser, FinSysTenantUser operatorUser, FinSysTenantUser monitorUser) { |
| | | //新增盘点单 |
| | | LWhFormInventory lWhFormInventory = new LWhFormInventory(); |
| | |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/10/31 |
| | | */ |
| | | @Override |
| | | public GenericPager<LWhFormInventory> queryList(LWhFormInventoryQry param, FinSysTenantUser sysInfo) { |
| | | StringBuilder sql = new StringBuilder(QUERY_LIST); |
| | | HashMap<String, Object> paramts = new HashMap<>(); |
| | |
| | | } |
| | | |
| | | |
| | | public void saveInventory(FormInventoryVO dto, Long id) { |
| | | @Override |
| | | public FormInventoryVO saveInventory(FormInventoryVO dto, Long id) { |
| | | //1.根据盘点单id查询盘点单 |
| | | LWhFormInventory lWhFormInventory = this.get(new LWhFormInventory(id)); |
| | | if (lWhFormInventory == null) { |
| | |
| | | if (CollectionUtils.isEmpty(formInventoryGoodsList)) { |
| | | log.error("盘点单物品为空"); |
| | | } |
| | | int num = inventoryGoodsService.add(formInventoryGoodsList, id); |
| | | if (num != formInventoryGoodsList.size()) { |
| | | log.error("更新盘点单物品失败"); |
| | | } |
| | | |
| | | List<FormInventoryGoodsVO> result = inventoryGoodsService.add(formInventoryGoodsList, id); |
| | | dto.setFormInventoryGoodsList(result); |
| | | return dto; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 保存盘点信息 |
| | |
| | | * @author 卢庆阳 |
| | | * @date 2023/10/31 |
| | | */ |
| | | public int updateInventoryInfo(LWhFormInventoryParam dto, Integer state) { |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public int updateInventoryInfo(LWhFormInventoryParam dto, Integer state, S_user_core currentUser, FinSysTenantUser sysInfo) { |
| | | //1.根据盘点单id查询盘点单 |
| | | LWhFormInventory lWhFormInventory = this.get(new LWhFormInventory(dto.getId())); |
| | | if (lWhFormInventory == null) { |
| | | log.error("根据盘点单id查询盘点单失败"); |
| | | return 0; |
| | | } |
| | | //2.修改盘点单 |
| | | //添加盘点单物品 |
| | | List<FormInventoryGoodsVO> inventoryGoodsList = dto.getInventoryGoodsList(); |
| | | if (CollectionUtils.isEmpty(inventoryGoodsList)) { |
| | | log.error("盘点单物品为空"); |
| | | return 0; |
| | | } |
| | | this.inventoryGoodsService.updateInventoryGoods(inventoryGoodsList); |
| | | //修改盘点单 |
| | | if (state == 2) { |
| | | //完成盘点时设置完成盘点时间 |
| | | lWhFormInventory.setStopTime(DateUtils.getDateTimeNumber(System.currentTimeMillis())); |
| | | |
| | | //完成盘点时设置完成盘点时间 |
| | | String inOutFormByInventoryId = lWhFormInventoryCoreService.createInOutFormByInventoryId(dto.getId(), currentUser, sysInfo); |
| | | if (!StringUtils.isEmpty(inOutFormByInventoryId)) { |
| | | log.error(inOutFormByInventoryId); |
| | | return 0; |
| | | } |
| | | } |
| | | lWhFormInventory.setStates(state); |
| | | lWhFormInventory.setInventoryDate(DateUtils.getDateTimeNumber(System.currentTimeMillis())); |
| | | int flag1 = this.update(lWhFormInventory); |
| | |
| | | log.error("修改盘点单失败"); |
| | | return 0; |
| | | } |
| | | //3.添加盘点单物品 |
| | | List<FormInventoryGoodsVO> inventoryGoodsList = dto.getInventoryGoodsList(); |
| | | if (CollectionUtils.isEmpty(inventoryGoodsList)) { |
| | | log.error("盘点单物品为空"); |
| | | return 0; |
| | | } |
| | | this.inventoryGoodsService.updateInventoryGoods(inventoryGoodsList); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | /** |
| | | * 完成盘点 |
| | | * |
| | | * @author 卢庆阳 |
| | | * @date 2023/10/31 |
| | | */ |
| | | // public int finishPd(LWhFormInventoryParam dto) { |
| | | // //1.根据盘点单id查询盘点单 |
| | | // LWhFormInventory lWhFormInventory = this.get(new LWhFormInventory(dto.getId())); |
| | | // if (lWhFormInventory == null) { |
| | | // log.error("根据盘点单id查询盘点单 失败"); |
| | | // return 0; |
| | | // } |
| | | // //2.修改盘点单 |
| | | // lWhFormInventory.setStates(2); |
| | | // lWhFormInventory.setStopTime(DateUtils.getDateTimeNumber(System.currentTimeMillis())); |
| | | // int flag1 = this.update(lWhFormInventory); |
| | | // if (flag1 == 0) { |
| | | // log.error("修改盘点单 失败"); |
| | | // return 0; |
| | | // } |
| | | // //3.更新盘点单物品 |
| | | // List<LWhFormInventoryGoods> inventoryGoodsList = dto.getInventoryGoodsList(); |
| | | // if (CollectionUtils.isEmpty(inventoryGoodsList)) { |
| | | // log.error("盘点单物品 为空"); |
| | | // return 0; |
| | | // } |
| | | // for (LWhFormInventoryGoods inventoryGoods : inventoryGoodsList) { |
| | | // int errorCounts = inventoryGoods.getInitCounts() - inventoryGoods.getInventoryCounts(); |
| | | // if (errorCounts > 0) { |
| | | // inventoryGoods.setInventoryResult(3); |
| | | // } else if (errorCounts < 0) { |
| | | // inventoryGoods.setInventoryResult(2); |
| | | // } else { |
| | | // inventoryGoods.setInventoryResult(1); |
| | | // } |
| | | // inventoryGoods.setErrorCounts(Math.abs(errorCounts)); |
| | | // } |
| | | // int flag2 = inventoryGoodsService.update(inventoryGoodsList); |
| | | // if (flag2 != inventoryGoodsList.size()) { |
| | | // log.error("更新盘点单物品 失败"); |
| | | // return 0; |
| | | // } |
| | | // return 1; |
| | | // } |
| | | |
| | | /** |
| | | * @return |
| | |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/11/1 |
| | | */ |
| | | @Override |
| | | public PageUtil<FormInventoryDetailVO> queryPdDetailList(LWhFormInventoryQry param, FinSysTenantUser sysInfo) { |
| | | StringBuilder sql = new StringBuilder(QUERY_PD_DETAIL_LIST); |
| | | HashMap<String, Object> paramts = new HashMap<>(); |
| | |
| | | formInventoryDetailVO.getInventoryResult() == null ? null : (formInventoryDetailVO.getInventoryResult() == 2 ? "盘盈" : "盘亏")); |
| | | formInventoryDetailVO.setInventoryType( |
| | | formInventoryDetailVO.getInventoryResult() == null ? null : (formInventoryDetailVO.getInventoryResult() == 2 ? "盘盈入库" : "盘亏出库")); |
| | | formInventoryDetailVO.setWarehouseFormCode(formInventoryDetailVO.getWarehouseFormCode()); |
| | | result.add(formInventoryDetailVO); |
| | | }); |
| | | pageUtil.setDatas(result); |
| | | return pageUtil; |
| | | } |
| | | |
| | | @Override |
| | | public List<FormInventoryGoodsVO> selectDetailById(Long id) { |
| | | |
| | | String sql = "select fig.id, fig.BASE_GOODS_TEMPLATE_ID,fig.GOODS_TEMPLATE_NAME,fig.BASE_GOODS_MODELS_NAME," |
| | |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public FormInventoryVO queryInventBaseGoodTemplate(Long id) { |
| | | FormInventoryVO formInventoryVO = new FormInventoryVO(); |
| | | |
| | |
| | | formInventoryVO.setWarehouseName(inventory.getWarehouseName()); |
| | | |
| | | String sql = |
| | | "select bgm.id,bgt.id baseGoodsTemplateId,bgt.GOODS_NAME goodsTemplateName,bgm.MODEL_NAME baseGoodsModelsName,bgt.CLASSIFICATION type,bgm.UNIT " |
| | | "select bgt.id baseGoodsTemplateId,bgt.GOODS_NAME goodsTemplateName,bgm.MODEL_NAME baseGoodsModelsName,bgt.CLASSIFICATION type,bgm.UNIT " |
| | | + "from base_goods_models bgm left join base_goods_template bgt on bgm.GOODS_TEMPLATES_ID = bgt.id " |
| | | + "where bgt.AGENCY_ID = :agencyId"; |
| | | HashMap<String, Object> param = new HashMap<>(); |
| | |
| | | formInventoryVO.setFormInventoryGoodsList(goodsVOList); |
| | | return formInventoryVO; |
| | | } |
| | | |
| | | @Override |
| | | public List<InventoryExcelTemplate> getExportList(Long id) { |
| | | String sql = "SELECT\n" |
| | | + "\tfi.INVENTORY_DATE createTime,\n" |
| | | + "\tfi.STOP_TIME endTime,\n" |
| | | + "\tfi.OPERATOR_NAME,\n" |
| | | + "\tfi.OPERATOR_NAME2 monitorName,\n" |
| | | + "\tfi.AGENCY_NAME tenantName,\n" |
| | | + "\tfig.GOODS_TEMPLATE_NAME templateName,\n" |
| | | + "\tfig.BASE_GOODS_MODELS_NAME baseModelName,\n" |
| | | + "\tfig.INVENTORY_COUNTS num,\n" |
| | | + "\tfig.INIT_COUNTS stockNum,\n" |
| | | + "\tfig.INVENTORY_RESULT,\n" |
| | | + "\tBEIZ1 remark\n" |
| | | + "FROM\n" |
| | | + "\tl_wh_form_inventory fi\n" |
| | | + "\tLEFT JOIN l_wh_form_inventory_goods fig ON fi.ID = fig.WH_FORM_INVENTORY_ID\n" |
| | | + "WHERE\n" |
| | | + "\tfi.ID = :id"; |
| | | HashMap<String, Object> param = new HashMap<>(); |
| | | param.put("id", id); |
| | | List<Map<String, Object>> select = this.select(sql, param, new MapperUtil()); |
| | | if (CollectionUtils.isEmpty(select)) { |
| | | return null; |
| | | } |
| | | List<InventoryExcelTemplate> list = Lists.newArrayList(); |
| | | select.forEach(item -> { |
| | | InventoryExcelTemplate inventoryExcelTemplate = MapUtils.convertMapToObj(item, InventoryExcelTemplate.class); |
| | | inventoryExcelTemplate.setInventoryDeception(inventoryExcelTemplate.getInventoryResult() == 1 ? "是" : "否"); |
| | | inventoryExcelTemplate.setDeception( |
| | | inventoryExcelTemplate.getInventoryResult() == 1 ? "正常" : (inventoryExcelTemplate.getInventoryResult() == 2 ? "盘盈" : "盘亏")); |
| | | list.add(inventoryExcelTemplate); |
| | | }); |
| | | return list; |
| | | |
| | | } |
| | | } |