kangwei : 采购计划统计接口
正在显示
18 个修改的文件
包含
347 行增加
和
26 行删除
... | @@ -12,6 +12,7 @@ import com.skua.modules.erp.entity.ApproveRecord; | ... | @@ -12,6 +12,7 @@ import com.skua.modules.erp.entity.ApproveRecord; |
12 | import com.skua.modules.erp.entity.PurchaseMaterial; | 12 | import com.skua.modules.erp.entity.PurchaseMaterial; |
13 | import com.skua.modules.erp.service.IDistributMaterialService; | 13 | import com.skua.modules.erp.service.IDistributMaterialService; |
14 | import com.skua.modules.erp.service.IPurchaseMaterialService; | 14 | import com.skua.modules.erp.service.IPurchaseMaterialService; |
15 | import com.skua.modules.erp.vo.MaterialSearchVO; | ||
15 | import com.skua.modules.supplies.entity.EquipmentSparepartSupplies; | 16 | import com.skua.modules.supplies.entity.EquipmentSparepartSupplies; |
16 | import com.skua.modules.supplies.service.IEquipmentSparepartSuppliesService; | 17 | import com.skua.modules.supplies.service.IEquipmentSparepartSuppliesService; |
17 | import com.skua.modules.system.entity.SysUser; | 18 | import com.skua.modules.system.entity.SysUser; |
... | @@ -36,16 +37,17 @@ public class ErpCommonController { | ... | @@ -36,16 +37,17 @@ public class ErpCommonController { |
36 | @Autowired | 37 | @Autowired |
37 | private IDistributMaterialService distributMaterialService; | 38 | private IDistributMaterialService distributMaterialService; |
38 | 39 | ||
39 | @AutoLog(value = "ERP-物料列表") | 40 | @AutoLog(value = "ERP-采购计划--物料列表") |
40 | @ApiOperation(value = "ERP-物料列表", notes = "ERP-物料列表") | 41 | @ApiOperation(value = "ERP-采购计划--物料列表", notes = "ERP-采购计划--物料列表") |
41 | @RequestMapping(value = "/sparepartList", method = RequestMethod.GET) | 42 | @RequestMapping(value = "/sparepartList", method = RequestMethod.GET) |
42 | public Result<IPage<EquipmentSparepartSupplies>> sparepartList(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, | 43 | public Result<IPage<EquipmentSparepartSupplies>> sparepartList(MaterialSearchVO materialSearchVO, |
43 | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) { | 44 | @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
45 | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) { | ||
44 | Result<IPage<EquipmentSparepartSupplies>> result = new Result<IPage<EquipmentSparepartSupplies>>(); | 46 | Result<IPage<EquipmentSparepartSupplies>> result = new Result<IPage<EquipmentSparepartSupplies>>(); |
45 | Page<EquipmentSparepartSupplies> page = new Page<EquipmentSparepartSupplies>(pageNo, pageSize); | 47 | Page<EquipmentSparepartSupplies> page = new Page<EquipmentSparepartSupplies>(pageNo, pageSize); |
46 | String depId = BaseContextHandler.getRealDepartId();//临时参数 | 48 | String depId = BaseContextHandler.getRealDepartId();//临时参数 |
47 | // String username = req.getParameter("username"); | 49 | // String username = req.getParameter("username"); |
48 | IPage<EquipmentSparepartSupplies> pageList = sparepartSuppliesService.queryPageByOut(page, depId); | 50 | IPage<EquipmentSparepartSupplies> pageList = sparepartSuppliesService.queryPageByOut(page, depId , materialSearchVO.getSparepartName() ,materialSearchVO.getSparepartType(),materialSearchVO.getSparepartCode()); |
49 | result.setSuccess(true); | 51 | result.setSuccess(true); |
50 | result.setResult(pageList); | 52 | result.setResult(pageList); |
51 | return result; | 53 | return result; | ... | ... |
... | @@ -158,4 +158,19 @@ public class PurchaseContractController { | ... | @@ -158,4 +158,19 @@ public class PurchaseContractController { |
158 | } | 158 | } |
159 | return result; | 159 | return result; |
160 | } | 160 | } |
161 | @AutoLog(value = "erp采购合同-同步入库") | ||
162 | @ApiOperation(value="erp采购合同-同步入库", notes="erp采购合同-同步入库") | ||
163 | @PutMapping(value = "/syncEquipmentIn") | ||
164 | public Result<String> syncEquipmentIn(@RequestParam(name="id",required=true) String id ) { | ||
165 | Result<String> result = new Result<String>(); | ||
166 | try { | ||
167 | PurchaseContractVO purchaseContractVO = purchaseContractService.queryById( id) ; | ||
168 | //调用接口,同步到入库单 | ||
169 | purchaseContractService.syncEquipmentIn(purchaseContractVO); | ||
170 | } catch (Exception e) { | ||
171 | log.error("同步入库失败",e.getMessage()); | ||
172 | result.setSuccess(true); | ||
173 | } | ||
174 | return result; | ||
175 | } | ||
161 | } | 176 | } | ... | ... |
... | @@ -46,6 +46,7 @@ public class ERPPurchaseContract { | ... | @@ -46,6 +46,7 @@ public class ERPPurchaseContract { |
46 | /**采购类型:招标采购/询价采购*/ | 46 | /**采购类型:招标采购/询价采购*/ |
47 | @Excel(name = "采购类型:招标采购/询价采购", width = 15) | 47 | @Excel(name = "采购类型:招标采购/询价采购", width = 15) |
48 | @ApiModelProperty(value = "采购类型:招标采购/询价采购") | 48 | @ApiModelProperty(value = "采购类型:招标采购/询价采购") |
49 | @Dict(dicCode = "purchase_type") | ||
49 | private java.lang.String purchaseType; | 50 | private java.lang.String purchaseType; |
50 | /**合同编号*/ | 51 | /**合同编号*/ |
51 | @Excel(name = "合同编号", width = 15) | 52 | @Excel(name = "合同编号", width = 15) |
... | @@ -90,6 +91,9 @@ public class ERPPurchaseContract { | ... | @@ -90,6 +91,9 @@ public class ERPPurchaseContract { |
90 | @ApiModelProperty(value = "申请时间") | 91 | @ApiModelProperty(value = "申请时间") |
91 | private String applyTime; | 92 | private String applyTime; |
92 | 93 | ||
94 | @Excel(name = "备注", width = 15) | ||
95 | @ApiModelProperty(value = "备注") | ||
96 | private String remark; | ||
93 | 97 | ||
94 | /**创建人id*/ | 98 | /**创建人id*/ |
95 | @Excel(name = "创建人id", width = 15) | 99 | @Excel(name = "创建人id", width = 15) |
... | @@ -123,4 +127,7 @@ public class ERPPurchaseContract { | ... | @@ -123,4 +127,7 @@ public class ERPPurchaseContract { |
123 | @Excel(name = "删除标识,0:有效,1:删除", width = 15) | 127 | @Excel(name = "删除标识,0:有效,1:删除", width = 15) |
124 | @ApiModelProperty(value = "删除标识,0:有效,1:删除") | 128 | @ApiModelProperty(value = "删除标识,0:有效,1:删除") |
125 | private java.lang.Integer delFlag; | 129 | private java.lang.Integer delFlag; |
130 | |||
131 | @ApiModelProperty(value = "删除标识,0:有效,1:删除") | ||
132 | private String equipmentInId; | ||
126 | } | 133 | } | ... | ... |
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
3 | <mapper namespace="com.skua.modules.erp.mapper.PurchasePlanMapper"> | 3 | <mapper namespace="com.skua.modules.erp.mapper.PurchasePlanMapper"> |
4 | |||
5 | |||
6 | <!-- 统计查询--> | 4 | <!-- 统计查询--> |
7 | <select id="statisticsPage" resultType="com.skua.modules.erp.entity.PurchasePlanItem"> | 5 | <select id="statisticsPage" resultType="com.skua.modules.erp.entity.PurchasePlanItem"> |
8 | select ss.sparepart_name,ss.sparepart_type,ss.specification,ss.measuring_unit, aaa.* from ( | 6 | select ss.id, ss.sparepart_name,ss.sparepart_type, st.item_text as 'sparepart_type_name' ,ss.sparepart_code, ss.specification,ss.measuring_unit, aaa.* from ( |
9 | select pi.sparepart_id,sum(pi.purchase_num ) as 'purchase_num' , sum(pi.total_price) 'total_price' | 7 | select pi.sparepart_id,sum(pi.purchase_num ) as 'purchase_num' , sum(pi.total_price) 'total_price' |
10 | from erp_purchase_plan_item pi ,erp_purchase_plan pp | 8 | from erp_purchase_plan_item pi ,erp_purchase_plan pp |
11 | where | 9 | where |
... | @@ -30,6 +28,7 @@ | ... | @@ -30,6 +28,7 @@ |
30 | group by pi.sparepart_id | 28 | group by pi.sparepart_id |
31 | )aaa | 29 | )aaa |
32 | left join equipment_sparepart_supplies ss on aaa.sparepart_id = ss.id | 30 | left join equipment_sparepart_supplies ss on aaa.sparepart_id = ss.id |
31 | left join equipment_sparepart_type st on st.id = aaa.sparepart_type | ||
33 | 32 | ||
34 | </select> | 33 | </select> |
35 | 34 | ... | ... |
... | @@ -55,6 +55,11 @@ public interface IEROPurchaseContractService extends IService<ERPPurchaseContrac | ... | @@ -55,6 +55,11 @@ public interface IEROPurchaseContractService extends IService<ERPPurchaseContrac |
55 | */ | 55 | */ |
56 | public void auditPurchaseContract(PurchaseContractVO purchaseContractVO); | 56 | public void auditPurchaseContract(PurchaseContractVO purchaseContractVO); |
57 | 57 | ||
58 | 58 | /*** | |
59 | * 同步入库操作 | ||
60 | * @param purchaseContractVO | ||
61 | * @return | ||
62 | */ | ||
63 | public int syncEquipmentIn(PurchaseContractVO purchaseContractVO)throws Exception; | ||
59 | 64 | ||
60 | } | 65 | } | ... | ... |
1 | package com.skua.modules.erp.service.impl; | 1 | package com.skua.modules.erp.service.impl; |
2 | 2 | ||
3 | import com.skua.core.context.BaseContextHandler; | 3 | import com.skua.core.context.BaseContextHandler; |
4 | import com.skua.core.util.DateUtils; | ||
5 | import com.skua.modules.equipment.dto.EquipmentInDTO; | ||
6 | import com.skua.modules.equipment.entity.EquipmentIn; | ||
7 | import com.skua.modules.equipment.entity.EquipmentInChild; | ||
8 | import com.skua.modules.equipment.service.IEquipmentInService; | ||
9 | import com.skua.modules.equipment.vo.EquipmentInExcel; | ||
4 | import com.skua.modules.erp.entity.*; | 10 | import com.skua.modules.erp.entity.*; |
5 | import com.skua.modules.erp.mapper.ApproveRecordMapper; | 11 | import com.skua.modules.erp.mapper.ApproveRecordMapper; |
6 | import com.skua.modules.erp.mapper.ERPPurchaseContractMapper; | 12 | import com.skua.modules.erp.mapper.ERPPurchaseContractMapper; |
7 | import com.skua.modules.erp.mapper.PurchaseMaterialMapper; | 13 | import com.skua.modules.erp.mapper.PurchaseMaterialMapper; |
8 | import com.skua.modules.erp.service.IEROPurchaseContractService; | 14 | import com.skua.modules.erp.service.IEROPurchaseContractService; |
9 | import com.skua.modules.erp.vo.PurchaseContractVO; | 15 | import com.skua.modules.erp.vo.PurchaseContractVO; |
16 | import com.skua.modules.guest.util.DateUtil; | ||
10 | import org.springframework.beans.BeanUtils; | 17 | import org.springframework.beans.BeanUtils; |
18 | import org.springframework.beans.factory.annotation.Autowired; | ||
11 | import org.springframework.stereotype.Service; | 19 | import org.springframework.stereotype.Service; |
12 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 20 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
13 | import org.springframework.transaction.annotation.Transactional; | 21 | import org.springframework.transaction.annotation.Transactional; |
14 | 22 | ||
15 | import javax.annotation.Resource; | 23 | import javax.annotation.Resource; |
24 | import java.math.BigDecimal; | ||
25 | import java.util.ArrayList; | ||
26 | import java.util.Date; | ||
16 | import java.util.List; | 27 | import java.util.List; |
28 | import java.util.UUID; | ||
17 | 29 | ||
18 | /** | 30 | /** |
19 | * 采购合同 | 31 | * 采购合同 |
... | @@ -27,6 +39,9 @@ public class ERPPurchaseContractServiceImpl extends ServiceImpl<ERPPurchaseContr | ... | @@ -27,6 +39,9 @@ public class ERPPurchaseContractServiceImpl extends ServiceImpl<ERPPurchaseContr |
27 | @Resource | 39 | @Resource |
28 | private ApproveRecordMapper recordMapper; | 40 | private ApproveRecordMapper recordMapper; |
29 | 41 | ||
42 | @Autowired | ||
43 | private IEquipmentInService equipmentInService; | ||
44 | |||
30 | /*** | 45 | /*** |
31 | * 新增purchaseContractVO | 46 | * 新增purchaseContractVO |
32 | * @param purchaseContractVO | 47 | * @param purchaseContractVO |
... | @@ -131,7 +146,56 @@ public class ERPPurchaseContractServiceImpl extends ServiceImpl<ERPPurchaseContr | ... | @@ -131,7 +146,56 @@ public class ERPPurchaseContractServiceImpl extends ServiceImpl<ERPPurchaseContr |
131 | recordMapper.insert( record ) ; | 146 | recordMapper.insert( record ) ; |
132 | // 审核通过,生成入库单据、物料单 | 147 | // 审核通过,生成入库单据、物料单 |
133 | if(inStock ){ | 148 | if(inStock ){ |
149 | try { | ||
150 | syncEquipmentIn(purchaseContractVO); | ||
151 | } catch (Exception e) { | ||
152 | e.printStackTrace(); | ||
153 | |||
154 | } | ||
155 | } | ||
156 | } | ||
157 | |||
134 | 158 | ||
159 | /*** | ||
160 | * 同步入库 | ||
161 | * @param purchaseContractVO | ||
162 | * @return | ||
163 | */ | ||
164 | public int syncEquipmentIn(PurchaseContractVO purchaseContractVO) throws Exception{ | ||
165 | EquipmentInDTO equipmentInDTO = new EquipmentInDTO(); | ||
166 | // EquipmentIn equipmentIn = new EquipmentIn(); | ||
167 | //入库类型 | ||
168 | equipmentInDTO.setDepartId( purchaseContractVO.getDepartId() );//所属厂站 | ||
169 | equipmentInDTO.setSuppliesWarehouseId( purchaseContractVO.getInWarehouseId() ) ;//入库仓库 | ||
170 | equipmentInDTO.setInDate(DateUtil.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss")); | ||
171 | equipmentInDTO.setUseBy( BaseContextHandler.getUserId() ) ;//经办人 | ||
172 | equipmentInDTO.setChooseTime( DateUtil.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss") );//经办时间 | ||
173 | equipmentInDTO.setRemark( purchaseContractVO.getRemark() );//备注 | ||
174 | |||
175 | List<EquipmentInChild> equipmentInChildrenList = new ArrayList<>(); | ||
176 | EquipmentInChild equipmentInChild = new EquipmentInChild();// | ||
177 | if(purchaseContractVO.getMaterialList() != null ){ | ||
178 | for( PurchaseMaterial purchaseMaterial : purchaseContractVO.getMaterialList()){ | ||
179 | equipmentInChild = new EquipmentInChild();// | ||
180 | equipmentInChild.setSparepartId( purchaseMaterial.getSparepartId());//物料编号 | ||
181 | equipmentInChild.setInNum( new BigDecimal(purchaseMaterial.getPurchaseNum())); //物料类别 | ||
182 | equipmentInChild.setBatchNum(purchaseMaterial.getGoodCode() ) ;//批次号 | ||
183 | |||
184 | equipmentInChildrenList.add( equipmentInChild ) ; | ||
185 | } | ||
135 | } | 186 | } |
187 | equipmentInDTO.setEquipmentInChildList( equipmentInChildrenList ); | ||
188 | //调用接口入库 | ||
189 | equipmentInService.saveEquipmentIn(equipmentInDTO ) ; | ||
190 | |||
191 | |||
192 | /* ERPPurchaseContract erpPurchaseContract = this.baseMapper.selectById(purchaseContractVO.getId()); | ||
193 | if(erpPurchaseContract == null ){ | ||
194 | throw new Exception("采购合同记录不存在"); | ||
195 | }*/ | ||
196 | purchaseContractVO.setEquipmentInId( equipmentInDTO.getId() ) ;//记录入库单号 | ||
197 | this.baseMapper.updateById(purchaseContractVO ) ; | ||
198 | return 1; | ||
136 | } | 199 | } |
200 | |||
137 | } | 201 | } | ... | ... |
1 | package com.skua.modules.erp.vo; | ||
2 | |||
3 | import com.skua.core.aspect.annotation.Dict; | ||
4 | import io.swagger.annotations.ApiModel; | ||
5 | import io.swagger.annotations.ApiModelProperty; | ||
6 | import lombok.Data; | ||
7 | import lombok.EqualsAndHashCode; | ||
8 | import lombok.experimental.Accessors; | ||
9 | |||
10 | @Data | ||
11 | @EqualsAndHashCode(callSuper = false) | ||
12 | @Accessors(chain = true) | ||
13 | @ApiModel(value="Material物料查询对象", description="Material物料查询对象") | ||
14 | public class MaterialSearchVO { | ||
15 | @ApiModelProperty(value = "物料编号") | ||
16 | private String sparepartCode; | ||
17 | |||
18 | @ApiModelProperty(value = "物料名称") | ||
19 | private String sparepartName; | ||
20 | |||
21 | @ApiModelProperty(value = "物料类型") | ||
22 | private String sparepartType; | ||
23 | |||
24 | @ApiModelProperty(value = "所属厂站") | ||
25 | private String departId; | ||
26 | } |
... | @@ -78,6 +78,20 @@ public class DangerLevelManageController { | ... | @@ -78,6 +78,20 @@ public class DangerLevelManageController { |
78 | result.setResult(pageList); | 78 | result.setResult(pageList); |
79 | return result; | 79 | return result; |
80 | } | 80 | } |
81 | |||
82 | |||
83 | @AutoLog(value = "风险分级管控清单-列表查询") | ||
84 | @ApiOperation(value="风险分级管控清单-列表查询", notes="风险分级管控清单-分页列表查询") | ||
85 | @GetMapping(value = "/dangerList") | ||
86 | public Result<List<DangerLevelManage>> queryByDangerList( @RequestParam(name="departId")String departId ) { | ||
87 | Result<List<DangerLevelManage>> result = new Result<List<DangerLevelManage>>(); | ||
88 | QueryWrapper<DangerLevelManage> queryWrapper = new QueryWrapper();//QueryGenerator.initQueryWrapper(dangerLevelManage, req.getParameterMap()); | ||
89 | queryWrapper.eq("depart_id" ,departId); | ||
90 | List<DangerLevelManage> pageList = dangerLevelManageService.list(queryWrapper); | ||
91 | result.setSuccess(true); | ||
92 | result.setResult(pageList); | ||
93 | return result; | ||
94 | } | ||
81 | 95 | ||
82 | /** | 96 | /** |
83 | * 添加 | 97 | * 添加 | ... | ... |
... | @@ -58,8 +58,9 @@ public class APPDangerInspectionRecordController { | ... | @@ -58,8 +58,9 @@ public class APPDangerInspectionRecordController { |
58 | Result<IPage<DangerInspectionRecord>> result = new Result<IPage<DangerInspectionRecord>>(); | 58 | Result<IPage<DangerInspectionRecord>> result = new Result<IPage<DangerInspectionRecord>>(); |
59 | QueryWrapper<DangerInspectionRecord> queryWrapper = new QueryWrapper<DangerInspectionRecord>();// QueryGenerator.initQueryWrapper(dangerInspectionRecord, req.getParameterMap()); | 59 | QueryWrapper<DangerInspectionRecord> queryWrapper = new QueryWrapper<DangerInspectionRecord>();// QueryGenerator.initQueryWrapper(dangerInspectionRecord, req.getParameterMap()); |
60 | Page<DangerInspectionRecord> page = new Page<DangerInspectionRecord>(pageNo, pageSize); | 60 | Page<DangerInspectionRecord> page = new Page<DangerInspectionRecord>(pageNo, pageSize); |
61 | queryWrapper.eq("danger_id", dangerInspectionRecord.getDangerId()); | 61 | if(dangerInspectionRecord.getDangerId() != null ){ |
62 | 62 | queryWrapper.eq("danger_id", dangerInspectionRecord.getDangerId()); | |
63 | } | ||
63 | if(StringUtils.isNotBlank(dangerInspectionRecord.getStartTime())){ | 64 | if(StringUtils.isNotBlank(dangerInspectionRecord.getStartTime())){ |
64 | queryWrapper.ge("report_date", dangerInspectionRecord.getStartTime() ) ; | 65 | queryWrapper.ge("report_date", dangerInspectionRecord.getStartTime() ) ; |
65 | } | 66 | } | ... | ... |
... | @@ -242,8 +242,6 @@ public class EquipmentInController { | ... | @@ -242,8 +242,6 @@ public class EquipmentInController { |
242 | @ApiOperation(value = "入库-添加", notes = "入库-添加") | 242 | @ApiOperation(value = "入库-添加", notes = "入库-添加") |
243 | @PostMapping(value = "/add") | 243 | @PostMapping(value = "/add") |
244 | public Result<Object> add(@RequestBody EquipmentInDTO equipmentInDTO) throws Exception { | 244 | public Result<Object> add(@RequestBody EquipmentInDTO equipmentInDTO) throws Exception { |
245 | |||
246 | |||
247 | List<SuppliesWarehouse> suppliesWarehouseList = suppliesWarehouseService.list(); | 245 | List<SuppliesWarehouse> suppliesWarehouseList = suppliesWarehouseService.list(); |
248 | Map<String, String> warehouseDictMap = suppliesWarehouseList.stream().collect(Collectors.toMap(SuppliesWarehouse::getId, SuppliesWarehouse::getDepartId)); | 246 | Map<String, String> warehouseDictMap = suppliesWarehouseList.stream().collect(Collectors.toMap(SuppliesWarehouse::getId, SuppliesWarehouse::getDepartId)); |
249 | Result<Object> result = new Result<>(); | 247 | Result<Object> result = new Result<>(); | ... | ... |
... | @@ -147,4 +147,20 @@ public class EquipmentIn { | ... | @@ -147,4 +147,20 @@ public class EquipmentIn { |
147 | @ApiModelProperty(value = "采购部门") | 147 | @ApiModelProperty(value = "采购部门") |
148 | @Dict(dicCode="departCode") | 148 | @Dict(dicCode="departCode") |
149 | private String purchaseDepart; | 149 | private String purchaseDepart; |
150 | |||
151 | public EquipmentIn( ) { | ||
152 | } | ||
153 | |||
154 | public EquipmentIn(String departId, String inOrder, String purchaseCode, String purchaseId, String inType, String inDate, String suppliesWarehouseId, Integer isConfirm, String chooseTime, String purchaseDepart) { | ||
155 | this.departId = departId; | ||
156 | this.inOrder = inOrder; | ||
157 | this.purchaseCode = purchaseCode; | ||
158 | this.purchaseId = purchaseId; | ||
159 | this.inType = inType; | ||
160 | this.inDate = inDate; | ||
161 | this.suppliesWarehouseId = suppliesWarehouseId; | ||
162 | this.isConfirm = isConfirm; | ||
163 | this.chooseTime = chooseTime; | ||
164 | this.purchaseDepart = purchaseDepart; | ||
165 | } | ||
150 | } | 166 | } | ... | ... |
... | @@ -2,6 +2,7 @@ package com.skua.modules.equipment.service; | ... | @@ -2,6 +2,7 @@ package com.skua.modules.equipment.service; |
2 | 2 | ||
3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
4 | import com.baomidou.mybatisplus.core.toolkit.Constants; | 4 | import com.baomidou.mybatisplus.core.toolkit.Constants; |
5 | import com.skua.modules.equipment.dto.EquipmentInDTO; | ||
5 | import com.skua.modules.equipment.entity.EquipmentIn; | 6 | import com.skua.modules.equipment.entity.EquipmentIn; |
6 | import com.baomidou.mybatisplus.extension.service.IService; | 7 | import com.baomidou.mybatisplus.extension.service.IService; |
7 | import com.skua.modules.equipment.vo.EquipmentInExcel; | 8 | import com.skua.modules.equipment.vo.EquipmentInExcel; |
... | @@ -17,4 +18,9 @@ public interface IEquipmentInService extends IService<EquipmentIn> { | ... | @@ -17,4 +18,9 @@ public interface IEquipmentInService extends IService<EquipmentIn> { |
17 | 18 | ||
18 | List<EquipmentInExcel> queryExport(@Param(Constants.WRAPPER) QueryWrapper<EquipmentIn> queryWrapper); | 19 | List<EquipmentInExcel> queryExport(@Param(Constants.WRAPPER) QueryWrapper<EquipmentIn> queryWrapper); |
19 | 20 | ||
21 | /*** | ||
22 | * 入库新增 | ||
23 | * @param equipmentInDTO | ||
24 | */ | ||
25 | public int saveEquipmentIn(EquipmentInDTO equipmentInDTO) throws Exception; | ||
20 | } | 26 | } | ... | ... |
1 | package com.skua.modules.equipment.service.impl; | 1 | package com.skua.modules.equipment.service.impl; |
2 | 2 | ||
3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
4 | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | ||
4 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 5 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
6 | import com.google.common.collect.Maps; | ||
7 | import com.skua.core.api.vo.Result; | ||
8 | import com.skua.core.exception.JeecgBootException; | ||
9 | import com.skua.core.util.ConvertUtils; | ||
10 | import com.skua.core.util.DateUtils; | ||
11 | import com.skua.modules.equipment.dto.EquipmentInDTO; | ||
5 | import com.skua.modules.equipment.entity.EquipmentIn; | 12 | import com.skua.modules.equipment.entity.EquipmentIn; |
13 | import com.skua.modules.equipment.entity.EquipmentInChild; | ||
14 | import com.skua.modules.equipment.entity.EquipmentSparepart; | ||
6 | import com.skua.modules.equipment.mapper.EquipmentInMapper; | 15 | import com.skua.modules.equipment.mapper.EquipmentInMapper; |
16 | import com.skua.modules.equipment.service.IEquipmentInChildService; | ||
7 | import com.skua.modules.equipment.service.IEquipmentInService; | 17 | import com.skua.modules.equipment.service.IEquipmentInService; |
18 | import com.skua.modules.equipment.service.IEquipmentSparepartService; | ||
19 | import com.skua.modules.equipment.service.ISupplierManageService; | ||
8 | import com.skua.modules.equipment.vo.EquipmentInExcel; | 20 | import com.skua.modules.equipment.vo.EquipmentInExcel; |
9 | import com.skua.modules.equipment.vo.EquipmentInVO; | 21 | import com.skua.modules.equipment.vo.EquipmentInVO; |
22 | import com.skua.modules.flow.utils.ObjectUtil; | ||
23 | import com.skua.modules.supplies.entity.EquipmentSparepartSupplies; | ||
24 | import com.skua.modules.supplies.entity.SuppliesWarehouse; | ||
25 | import com.skua.modules.supplies.mapper.PurchaseInfoMapper; | ||
26 | import com.skua.modules.supplies.service.IEquipmentSparepartSuppliesService; | ||
27 | import com.skua.modules.supplies.service.IPurchaseInfoDetailService; | ||
28 | import com.skua.modules.supplies.service.ISuppliesWarehouseService; | ||
29 | import com.skua.tool.util.BeanExtUtils; | ||
30 | import org.apache.commons.lang.StringUtils; | ||
31 | import org.springframework.beans.BeanUtils; | ||
10 | import org.springframework.beans.factory.annotation.Autowired; | 32 | import org.springframework.beans.factory.annotation.Autowired; |
33 | import org.springframework.beans.factory.annotation.Qualifier; | ||
34 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
11 | import org.springframework.stereotype.Service; | 35 | import org.springframework.stereotype.Service; |
36 | import org.springframework.transaction.support.TransactionTemplate; | ||
12 | 37 | ||
38 | import javax.annotation.Resource; | ||
39 | import java.math.BigDecimal; | ||
40 | import java.util.Date; | ||
13 | import java.util.List; | 41 | import java.util.List; |
42 | import java.util.Map; | ||
43 | import java.util.UUID; | ||
44 | import java.util.concurrent.CountDownLatch; | ||
45 | import java.util.stream.Collectors; | ||
14 | 46 | ||
15 | /** | 47 | /** |
16 | * 入库 | 48 | * 入库 |
17 | */ | 49 | */ |
18 | @Service | 50 | @Service |
19 | public class EquipmentInServiceImpl extends ServiceImpl<EquipmentInMapper, EquipmentIn> implements IEquipmentInService { | 51 | public class EquipmentInServiceImpl extends ServiceImpl<EquipmentInMapper, EquipmentIn> implements IEquipmentInService { |
20 | @Autowired | 52 | @Resource |
21 | private EquipmentInMapper equipmentInMapper; | 53 | private EquipmentInMapper equipmentInMapper; |
22 | 54 | @Autowired | |
55 | private TransactionTemplate transactionTemplate;//事务 | ||
56 | @Autowired | ||
57 | private IEquipmentInChildService iEquipmentInChildService; | ||
58 | @Qualifier(value = "taskExecutor") | ||
59 | @Autowired | ||
60 | private ThreadPoolTaskExecutor taskExecutor; | ||
61 | @Autowired | ||
62 | private IEquipmentSparepartSuppliesService sparepartSuppliesService; | ||
63 | @Autowired | ||
64 | private IEquipmentSparepartService iEquipmentSparepartService; | ||
65 | @Autowired | ||
66 | private ISuppliesWarehouseService suppliesWarehouseService; | ||
23 | @Override | 67 | @Override |
24 | public List<EquipmentInExcel> queryExport(QueryWrapper<EquipmentIn> queryWrapper) { | 68 | public List<EquipmentInExcel> queryExport(QueryWrapper<EquipmentIn> queryWrapper) { |
25 | return equipmentInMapper.queryExport(queryWrapper); | 69 | return equipmentInMapper.queryExport(queryWrapper); |
26 | } | 70 | } |
27 | 71 | ||
28 | |||
29 | /*** | 72 | /*** |
30 | * 新增录入 | 73 | * 入库 |
31 | * @param equipmentIn | 74 | * @param equipmentInDTO |
32 | * @return | 75 | * @throws Exception |
33 | */ | 76 | */ |
34 | public int saveEquipmentIn(EquipmentIn equipmentIn){ | 77 | public int saveEquipmentIn(EquipmentInDTO equipmentInDTO) throws Exception { |
78 | List<SuppliesWarehouse> suppliesWarehouseList = suppliesWarehouseService.list();//供应商列表 | ||
79 | Map<String, String> warehouseDictMap = suppliesWarehouseList.stream().collect(Collectors.toMap(SuppliesWarehouse::getId, SuppliesWarehouse::getDepartId)); | ||
35 | 80 | ||
81 | if (equipmentInDTO.getEquipmentInChildList() == null || equipmentInDTO.getEquipmentInChildList().isEmpty()) { | ||
82 | throw new JeecgBootException("请选择入库备件!"); | ||
83 | } | ||
84 | if (StringUtils.isBlank(equipmentInDTO.getSuppliesWarehouseId())) { | ||
85 | throw new JeecgBootException("请选择入库仓库!"); | ||
86 | } | ||
87 | /*if (StringUtils.isBlank(equipmentInDTO.getInType())) { | ||
88 | throw new JeecgBootException("请选择入库类型!"); | ||
89 | }*/ | ||
90 | // 入库单号 | ||
91 | if (StringUtils.isEmpty(equipmentInDTO.getInOrder())) { | ||
92 | String inOrder = "RK-" + DateUtils.format(new Date(), "YYYYMMdd" + "-" + System.currentTimeMillis()); | ||
93 | equipmentInDTO.setInOrder(inOrder); | ||
94 | } | ||
95 | // 入库表主键 | ||
96 | String inId = UUID.randomUUID().toString().replaceAll("-", ""); | ||
97 | equipmentInDTO.setId(inId); | ||
98 | EquipmentIn equipmentIn = BeanExtUtils.bean2Bean(equipmentInDTO, EquipmentIn.class); | ||
99 | equipmentIn.setIsConfirm(1); | ||
100 | transactionTemplate.execute((transactionStatus -> { | ||
101 | // equipmentInService.save(equipmentIn); | ||
102 | this.baseMapper.insert(equipmentIn); | ||
103 | return 1; | ||
104 | })); | ||
105 | CountDownLatch countDownLatch = new CountDownLatch(equipmentInDTO.getEquipmentInChildList().size()); | ||
106 | /* //如果是采购入库 | ||
107 | Map<String, PurchaseInfoDetail> purchaseMap = Maps.newHashMap(); | ||
108 | if ("cg".equals(equipmentInDTO.getInType()) && StringUtils.isNotEmpty(equipmentInDTO.getPurchaseCode())) { | ||
109 | String purchaseId = equipmentInDTO.getPurchaseId(); | ||
110 | PurchaseInfo purchaseInfo = purchaseInfoMapper.selectById(purchaseId); | ||
111 | List<PurchaseInfoDetail> purchaseInfoDetails = purchaseInfoDetailService.list( (new QueryWrapper<PurchaseInfoDetail>().eq( "purchase_info_id", purchaseInfo.getId() )) ); | ||
112 | for (PurchaseInfoDetail purchaseInfoDetail : purchaseInfoDetails) { | ||
113 | purchaseMap.put(purchaseInfoDetail.getSparepartId(), purchaseInfoDetail); | ||
114 | } | ||
115 | }*/ | ||
116 | for (EquipmentInChild equipmentInChild : equipmentInDTO.getEquipmentInChildList()) { | ||
117 | equipmentInChild.setInId(inId); | ||
118 | taskExecutor.execute(() -> { | ||
119 | try { | ||
120 | String sparepartId = equipmentInChild.getSparepartId(); | ||
121 | String suppliesWarehouseId = equipmentInDTO.getSuppliesWarehouseId(); | ||
122 | //根据物资id和仓库id获取库存 | ||
123 | QueryWrapper<EquipmentSparepart> sparepartQueryWrapper = new QueryWrapper<>(); | ||
124 | sparepartQueryWrapper.eq("supplies_id", sparepartId).eq("supplies_warehouse_id", suppliesWarehouseId); | ||
125 | EquipmentSparepart equipmentSparepart = iEquipmentSparepartService.getOne(sparepartQueryWrapper); | ||
126 | if (ObjectUtil.isEmpty(equipmentSparepart)) { | ||
127 | //物料信息 | ||
128 | EquipmentSparepartSupplies supplies = sparepartSuppliesService.getById(sparepartId); | ||
129 | equipmentSparepart = new EquipmentSparepart(); | ||
130 | BeanUtils.copyProperties(supplies, equipmentSparepart); | ||
131 | equipmentSparepart.setId(null); | ||
132 | equipmentSparepart.setStorageNum(BigDecimal.ZERO); | ||
133 | equipmentSparepart.setSuppliesId(sparepartId); | ||
134 | equipmentSparepart.setSuppliesWarehouseId(suppliesWarehouseId); | ||
135 | equipmentSparepart.setDepartId(warehouseDictMap.get(suppliesWarehouseId)); | ||
136 | //如果没有物料库存信息,新增库存信息为0 | ||
137 | iEquipmentSparepartService.saveOrUpdate(equipmentSparepart); | ||
138 | equipmentSparepart = iEquipmentSparepartService.getOne(sparepartQueryWrapper); | ||
139 | } | ||
36 | 140 | ||
37 | return 0 ; | 141 | BigDecimal resetStorageNum = equipmentSparepart.getStorageNum().add(equipmentInChild.getInNum()); |
142 | equipmentSparepart.setStorageNum(resetStorageNum); | ||
143 | equipmentInChild.setCurStorageNum(resetStorageNum); | ||
144 | Integer version = equipmentSparepart.getVersion(); | ||
145 | String id = equipmentSparepart.getId(); | ||
146 | Integer executeRes = transactionTemplate.execute(transactionStatus -> { | ||
147 | iEquipmentSparepartService.updateStorageNumById(id, resetStorageNum.doubleValue(), version); | ||
148 | iEquipmentInChildService.saveOrUpdate(equipmentInChild); | ||
149 | //=========== | ||
150 | //如果是采购入库 | ||
151 | /* if ("cg".equals(equipmentInDTO.getInType()) && StringUtils.isNotEmpty(equipmentInDTO.getPurchaseCode())) { | ||
152 | BigDecimal inNum = equipmentInChild.getInNum(); | ||
153 | PurchaseInfoDetail purchaseInfoDetail = purchaseMap.get(sparepartId); | ||
154 | //剩余采购物料数量 | ||
155 | Double realTimeCount = ConvertUtils.getDouble(purchaseInfoDetail.getRealTimeCount(), 0); | ||
156 | Double real = new BigDecimal(realTimeCount).subtract(inNum).doubleValue(); | ||
157 | purchaseInfoDetail.setRealTimeCount(real < 0 ? "0" : ConvertUtils.getString(ConvertUtils.getDouble(real, 0, 2))); | ||
158 | //采购数量 | ||
159 | String count = purchaseInfoDetail.getCount(); | ||
160 | //已经入库数量 | ||
161 | purchaseInfoDetail.setInCount(ConvertUtils.getString(ConvertUtils.getDouble(count, 0) - ConvertUtils.getDouble(real, 0))); | ||
162 | UpdateWrapper<PurchaseInfoDetail> purchaseInfoDetailUpdateWrapper = new UpdateWrapper<>(); | ||
163 | int detailVersion = purchaseInfoDetail.getVersion(); | ||
164 | purchaseInfoDetailUpdateWrapper.eq("version", detailVersion).eq("id", purchaseInfoDetail.getId()).set("version", detailVersion + 1); | ||
165 | purchaseInfoDetailService.update(purchaseInfoDetail, purchaseInfoDetailUpdateWrapper); | ||
166 | }*/ | ||
167 | //============= | ||
168 | return 1; | ||
169 | }); | ||
170 | } catch (Exception e1) { | ||
171 | e1.printStackTrace(); | ||
172 | // log.error("异常error: {}", e1.getMessage()); | ||
173 | } finally { | ||
174 | countDownLatch.countDown(); | ||
175 | } | ||
176 | }); | ||
177 | } | ||
178 | countDownLatch.await(); | ||
179 | return 1; | ||
38 | } | 180 | } |
181 | |||
182 | |||
183 | |||
39 | } | 184 | } | ... | ... |
... | @@ -257,4 +257,15 @@ public class EquipmentSparepartSupplies { | ... | @@ -257,4 +257,15 @@ public class EquipmentSparepartSupplies { |
257 | @TableField(exist=false) | 257 | @TableField(exist=false) |
258 | @ApiModelProperty(value = "计划采购数量") | 258 | @ApiModelProperty(value = "计划采购数量") |
259 | private String purchaseNum; | 259 | private String purchaseNum; |
260 | |||
261 | |||
262 | @TableField(exist=false) | ||
263 | @ApiModelProperty(value = "计划采购数量") | ||
264 | private String sparepartId; | ||
265 | |||
266 | public String getSparepartId() { | ||
267 | return id; | ||
268 | } | ||
269 | |||
270 | |||
260 | } | 271 | } | ... | ... |
... | @@ -18,5 +18,7 @@ public interface EquipmentSparepartSuppliesMapper extends BaseMapper<EquipmentSp | ... | @@ -18,5 +18,7 @@ public interface EquipmentSparepartSuppliesMapper extends BaseMapper<EquipmentSp |
18 | * @param depId | 18 | * @param depId |
19 | * @return | 19 | * @return |
20 | */ | 20 | */ |
21 | public IPage<EquipmentSparepartSupplies> queryPageByOut(Page<EquipmentSparepartSupplies> page, String depId); | 21 | public IPage<EquipmentSparepartSupplies> queryPageByOut(Page<EquipmentSparepartSupplies> page, |
22 | @Param("depId") String depId ,@Param("sparepartName")String sparepartName, | ||
23 | @Param("sparepartType")String sparepartType ,@Param("sparepartCode")String sparepartCode); | ||
22 | } | 24 | } | ... | ... |
... | @@ -6,12 +6,22 @@ | ... | @@ -6,12 +6,22 @@ |
6 | <select id="queryPageByOut" resultType="com.skua.modules.supplies.entity.EquipmentSparepartSupplies"> | 6 | <select id="queryPageByOut" resultType="com.skua.modules.supplies.entity.EquipmentSparepartSupplies"> |
7 | select st.item_text 'sparepart_type_name' , aaa.out_num, ss.* from equipment_sparepart_supplies ss | 7 | select st.item_text 'sparepart_type_name' , aaa.out_num, ss.* from equipment_sparepart_supplies ss |
8 | left join equipment_sparepart_type st on ss.sparepart_type = st.id | 8 | left join equipment_sparepart_type st on ss.sparepart_type = st.id |
9 | |||
10 | left join ( | 9 | left join ( |
11 | select sum(out_num) out_num ,sparepart_id from equipment_out_child | 10 | select sum(out_num) out_num ,sparepart_id from equipment_out_child |
12 | where | 11 | where |
13 | YEAR(create_time) = YEAR(CURRENT_DATE - INTERVAL 1 YEAR) | 12 | YEAR(create_time) = YEAR(CURRENT_DATE - INTERVAL 1 YEAR) |
14 | group by sparepart_id | 13 | group by sparepart_id |
15 | ) aaa on aaa.sparepart_id = ss.id | 14 | ) aaa on aaa.sparepart_id = ss.id |
15 | <where> | ||
16 | <if test="sparepartName != null and sparepartName !=''"> | ||
17 | and ss.sparepart_name like CONCAT('%', #{sparepartName},'%') | ||
18 | </if> | ||
19 | <if test="sparepartCode != null and sparepartCode !=''"> | ||
20 | and ss.sparepart_code like CONCAT('%', #{sparepartCode},'%') | ||
21 | </if> | ||
22 | <if test="sparepartType != null and sparepartType !=''"> | ||
23 | and ss.sparepart_type = #{sparepartType} | ||
24 | </if> | ||
25 | </where> | ||
16 | </select> | 26 | </select> |
17 | </mapper> | 27 | </mapper> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -15,5 +15,5 @@ public interface IEquipmentSparepartSuppliesService extends IService<EquipmentSp | ... | @@ -15,5 +15,5 @@ public interface IEquipmentSparepartSuppliesService extends IService<EquipmentSp |
15 | * @param depId | 15 | * @param depId |
16 | * @return | 16 | * @return |
17 | */ | 17 | */ |
18 | public IPage<EquipmentSparepartSupplies> queryPageByOut(Page<EquipmentSparepartSupplies> page, String depId); | 18 | public IPage<EquipmentSparepartSupplies> queryPageByOut(Page<EquipmentSparepartSupplies> page, String depId ,String sparepartName,String sparepartType ,String sparepartCode); |
19 | } | 19 | } | ... | ... |
... | @@ -20,7 +20,7 @@ public class EquipmentSparepartSuppliesServiceImpl extends ServiceImpl<Equipment | ... | @@ -20,7 +20,7 @@ public class EquipmentSparepartSuppliesServiceImpl extends ServiceImpl<Equipment |
20 | * @param depId | 20 | * @param depId |
21 | * @return | 21 | * @return |
22 | */ | 22 | */ |
23 | public IPage<EquipmentSparepartSupplies> queryPageByOut(Page<EquipmentSparepartSupplies> page, String depId){ | 23 | public IPage<EquipmentSparepartSupplies> queryPageByOut(Page<EquipmentSparepartSupplies> page, String depId ,String sparepartName,String sparepartType ,String sparepartCode){ |
24 | return baseMapper.queryPageByOut(page,depId); | 24 | return baseMapper.queryPageByOut(page,depId ,sparepartName,sparepartType,sparepartCode); |
25 | } | 25 | } |
26 | } | 26 | } | ... | ... |
-
请 注册 或 登录 后发表评论