|
@@ -85,8 +85,8 @@ public class BusinessServiceImpl implements BusinessService{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- String sql="insert into a_production_order (order_code, production_order_code, order_name, product_name, product_code, plan_amount, status, sales_order_id, product_id,is_issue,is_plan) values (?,?,?,?,?,?,?,?,?,?,?)";
|
|
|
- jdbcService.insert("执行insert",sql,orderCode,generateSerial.generateSerialNumber("aProductionOrder"),orderName,productName,productCode,salesAmount,0,salesOrderId,productId,0,0);
|
|
|
+ String sql="insert into a_production_order (order_code, production_order_code, order_name, product_name, product_code, plan_amount, status, sales_order_id, product_id,is_issue,is_plan,created_at) values (?,?,?,?,?,?,?,?,?,?,?,?)";
|
|
|
+ jdbcService.insert("执行insert",sql,orderCode,generateSerial.generateSerialNumber("aProductionOrder"),orderName,productName,productCode,salesAmount,0,salesOrderId,productId,0,0,new Date());
|
|
|
});
|
|
|
jdbcService.update("update b_sales_order set is_issue = 1 where id = ?",id);
|
|
|
}
|
|
@@ -366,12 +366,14 @@ public class BusinessServiceImpl implements BusinessService{
|
|
|
|
|
|
@Override
|
|
|
public void reportAmount(Long id, Map<String, Object> map) {
|
|
|
+ //当前报工数量
|
|
|
Integer reportAmount = Integer.valueOf(map.get("amount").toString());
|
|
|
|
|
|
Map<String, Object> one = jdbcService.findOne("select * from a_production_work_order where id = ?", id);
|
|
|
Integer amount=0;
|
|
|
Integer seq = Integer.valueOf(one.get("seq").toString());
|
|
|
String productionOrderCode=one.get("productionOrderCode").toString();
|
|
|
+ //之前报工数量
|
|
|
Integer reportAmount1 = Integer.valueOf(one.get("reportAmount").toString());
|
|
|
Integer scrapAmount = Integer.valueOf(one.get("scrapAmount").toString());
|
|
|
Integer planAmount = 0;
|
|
@@ -422,6 +424,13 @@ public class BusinessServiceImpl implements BusinessService{
|
|
|
Long salesOrderId = Long.valueOf(one.get("salesOrderId").toString());
|
|
|
Integer reportAmount=Integer.valueOf(one.get("reportAmount").toString());
|
|
|
String workCode = one.get("workCode").toString();
|
|
|
+
|
|
|
+ Map<String, Object> defectiveCount = jdbcService.findOne("select count(*) as num from a_defective_products where if_defective = 0 and production_work_order=?", id);
|
|
|
+ Integer count = Integer.valueOf(defectiveCount.get("num").toString());
|
|
|
+ if(count > 0){
|
|
|
+ throw new RuntimeException("还有"+count +"条不良品记录未处理");
|
|
|
+ }
|
|
|
+
|
|
|
//最后一道工序入库
|
|
|
if(id.equals(endId)){
|
|
|
Map<String, Object> flag = jdbcService.findOne("select * from a_product_store where parent_id = (select product_id from a_production_order where id = ?)", productionOrderId);
|
|
@@ -573,6 +582,59 @@ public class BusinessServiceImpl implements BusinessService{
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void defectiveAmount(Long id, Map<String, Object> map) {
|
|
|
+
|
|
|
+ Integer amount = Integer.valueOf(map.get("amount").toString());
|
|
|
+ Map<String, Object> one = jdbcService.findOne("select * from a_production_work_order where id=?", id);
|
|
|
+ String workCode = one.get("workCode").toString();
|
|
|
+ String insertSql="\tINSERT INTO a_defective_products (`work_code`, `production_work_order`, `amount`, `if_defective`, `created_at`, `created_by`, `updated_at`, `updated_by`) VALUES (?, ?, ?, ?, ?, ?, ?, ?);\n";
|
|
|
+ jdbcService.insert("insert",insertSql,workCode,id,amount,0,new Date(),getUserId(),null,null);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void saveDefectiveDetail(Map<String, Object> map) {
|
|
|
+ Long id = Long.valueOf(map.get("id").toString());
|
|
|
+ //总的不良判断数量
|
|
|
+ Integer amount = Integer.valueOf(map.get("amount").toString());
|
|
|
+ Long productionWorkOrderId = Long.valueOf(map.get("productionWorkOrder").toString());
|
|
|
+ String workCode = map.get("workCode").toString();
|
|
|
+ List<Map> list=(List)map.get("aDefectiveProductsDetailItem");
|
|
|
+ int detailAmountSum = list.stream()
|
|
|
+ .mapToInt(item -> Integer.valueOf(item.getOrDefault("amount", 0).toString())) // 获取每个Map中的amount值,如果不存在则默认为0
|
|
|
+ .sum();// 求和
|
|
|
+ /* int jixuSum = list.stream().filter(item1 -> item1.containsKey("defective") && item1.get("defective").equals(1))
|
|
|
+ .mapToInt(item -> Integer.valueOf(item.getOrDefault("amount", 0).toString())) // 获取每个Map中的amount值,如果不存在则默认为0
|
|
|
+ .sum();// 求和*/
|
|
|
+ if(detailAmountSum > amount){
|
|
|
+ throw new RuntimeException("不良品判断数量超过总数");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ jdbcService.update("update a_defective_products set if_defective=1,updated_at=now(),updated_by=? where id=?",getUserId(),id);
|
|
|
+
|
|
|
+ String insertSql="INSERT INTO a_defective_products_detail (`defective_products_id`, `amount`, `ifDefective`, `created_at`, `created_by`, `seq`) VALUES (?, ?, ?, ?, ?, ?);\n";
|
|
|
+ StringBuffer insert=new StringBuffer("INSERT INTO a_work_report_record ( production_work_order_id, report_amount, created_at, created_by) " +
|
|
|
+ "VALUES ( ?, ?, ?, ?);");
|
|
|
+ String scrap="INSERT INTO a_work_scrap ( scrap_code, work_code, scrap_amount, scrap_person, scrap_reason, apply_status, create_time, production_work_order_id,scrap_file) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
|
|
+ for(int i=0;i<list.size();i++){
|
|
|
+ Map m = list.get(i);
|
|
|
+ Integer detailAmount = Integer.valueOf(m.get("amount").toString());
|
|
|
+ Integer ifdefective = Integer.valueOf(m.get("ifdefective").toString());
|
|
|
+ jdbcService.insert("insert",insertSql,id,detailAmount,ifdefective,new Date(),getUserId(),i);
|
|
|
+
|
|
|
+ if (ifdefective==1){
|
|
|
+ jdbcService.update("update a_production_work_order set report_amount=report_amount+"+detailAmount+" where id=?",productionWorkOrderId);
|
|
|
+ jdbcService.insert("执行insert",insert.toString(),productionWorkOrderId,detailAmount,new Date(),getUserId());
|
|
|
+ } else if (ifdefective==2) {
|
|
|
+ jdbcService.update("update a_production_work_order set scrap_amount=scrap_amount+"+detailAmount+" where id=?",productionWorkOrderId);
|
|
|
+ jdbcService.insert("执行sql",scrap,generateSerial.generateSerialNumber("aWorkScrap"),workCode,detailAmount,getUserId(),null,0,new Date(),productionWorkOrderId,null);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 销售订单id
|
|
|
* @param id
|