Index: ssts-packing/src/main/java/com/forgon/disinfectsystem/packing/service/PackingManager.java =================================================================== diff -u -r37371 -r38291 --- ssts-packing/src/main/java/com/forgon/disinfectsystem/packing/service/PackingManager.java (.../PackingManager.java) (revision 37371) +++ ssts-packing/src/main/java/com/forgon/disinfectsystem/packing/service/PackingManager.java (.../PackingManager.java) (revision 38291) @@ -404,4 +404,19 @@ * @return */ public JSONArray getTousseInstanceSetCodeByTousseInstanceIdsForPrint(String ids); + /** + * 删除装配任务 + * @param deleteCause 删除原因 + * @param idStr 删除的id + * @param tousseID 包定义id + * @param notLossReport true:不是丢失报损行 false:丢失报损行(因为页面上对于一个有丢失报损的装配任务是显示两行的 此参数主要是区分用户删的是其中的哪一行) + * @param amount 删除的装配任务数量 + */ + public void deletePackingTask(String deleteCause, String idStr, Long tousseID, boolean notLossReport, Integer amount); + /** + * 批量终止装配任务 + * @param deleteInfo 终止的装配任务信息 例如终止两个装配任务,注意如果终止的是丢失报损那行,notLossReport为true; [{"notLossReport":true,"packingTaskId":4261,"amount":1},{"notLossReport":true,"packingTaskId":4262,"amount":2}] + * @param deleteCause 转配原因 + */ + public void deletePackingTasks(JSONArray deleteInfo, String deleteCause); } Index: ssts-packing/src/main/java/com/forgon/disinfectsystem/packing/action/PackingAction.java =================================================================== diff -u -r37759 -r38291 --- ssts-packing/src/main/java/com/forgon/disinfectsystem/packing/action/PackingAction.java (.../PackingAction.java) (revision 37759) +++ ssts-packing/src/main/java/com/forgon/disinfectsystem/packing/action/PackingAction.java (.../PackingAction.java) (revision 38291) @@ -657,64 +657,18 @@ public void deletePackingTask() { String idStr = StrutsParamUtils.getPraramValue("ids", ""); - Long tousseID = StrutsParamUtils.getPraramLongValue("tousseID", null); + String deleteCause = StrutsParamUtils.getPraramValue("deleteCause", ""); + boolean notLossReport = StrutsParamUtils.getBoolPraramValue("notLossReport", true); + Integer amount = StrutsParamUtils.getPraramValue("amount", 0); + Long tousseID = StrutsParamUtils.getPraramLongValue("tousseID", null); boolean success = false; String cause = null; try { - if (StringUtils.isNotBlank(idStr)) { - if(StringUtils.isBlank(deleteCause)){ - deleteCause = PackingTask.DELETE_CAUSE_MANUAL; - } - if(!DatabaseUtil.isPoIdValid(tousseID) || idStr.contains(";")){//批量删除 - String[] str = idStr.split(";"); - for (String id : str) { - PackingTask packingTask = packingManager.get(id); - packingManager.delete(packingTask,deleteCause); - } - }else{ - Integer amount = StrutsParamUtils.getPraramValue("amount", 0); - PackingTask packingTask = packingManager.get(idStr); - Integer unPackAmount = packingTask.getUnPackAmount() - amount; - boolean notLossReport = StrutsParamUtils.getBoolPraramValue("notLossReport", true); - if(!notLossReport){//丢失报损行... - String whereSql = String.format(" where po.packingTaskId=%s and tousseDefinitionId=%s ", idStr,tousseID); - List medds = objectDao.findBySql(MaterialErrorDamageDetail.class.getSimpleName(), - whereSql); - if(CollectionUtils.isNotEmpty(medds)){ - TousseDefinition td = tousseDefinitionManager.get(tousseID); - String tousseName = ""; - if(td != null){ - tousseName = td.getName(); - } - for (MaterialErrorDamageDetail medd : medds) { - medd.setStatus(MaterialErrorDamageDetail.STATUS_ONE);//从装配任务处删除 - objectDao.update(medd); - String msgType = null; - if(MaterialErrorDamageDetail.TYPE_ERROR.equals(medd.getType())){ - msgType = "丢失"; - }else if(MaterialErrorDamageDetail.TYPE_DAMAGE.equals(medd.getType())){ - msgType = "报损"; - }else{ - msgType = "未知的丢失或报损"; - } - String message = String.format("删除了有器械%s的待装配任务,装配任务id:%s,物品名称:%s,包定义id:%s,数量:%s,%s的器械:%s,器械材料定义id:%s,数量:%s", - msgType,idStr,tousseName,tousseID,medd.getAmount(),msgType,medd.getMaterialName(),medd.getMaterialDefinitionId(),medd.getAmount()*medd.getAmountPerTousse()); - appLogManager.saveLog(AcegiHelper.getLoginUser(), Log.MODEL_PACKING, - Log.TYPE_DELETE, message); - } - } - } - if(unPackAmount <= 0){ - packingManager.delete(packingTask,deleteCause); - }else{ - packingTask.setUnPackAmount(unPackAmount); - objectDao.update(packingTask); - } - } - success = true; + packingManager.deletePackingTask(deleteCause, idStr, tousseID, notLossReport, amount); } + success = true; } catch (Exception e) { success = false; e.printStackTrace(); @@ -1467,4 +1421,33 @@ } StrutsResponseUtils.output(retObj); } + /** + * 批量终止装配任务 + * deleteInfo 终止的装配任务信息 例如终止两个装配任务,注意如果终止的是丢失报损那行,notLossReport为true; [{"notLossReport":true,"packingTaskId":4261,"amount":1},{"notLossReport":true,"packingTaskId":4262,"amount":2}] + * deleteCause 终止原因 + */ + public void batchUpdatePackingTask(){ + String deleteInfo = StrutsParamUtils.getPraramValue("deleteInfo", ""); + String deleteCause = StrutsParamUtils.getPraramValue("deleteCause", ""); + boolean success = false; + String cause = null; + try { + if (StringUtils.isNotBlank(deleteInfo)) { + packingManager.deletePackingTasks(JSONArray.fromObject(deleteInfo), deleteCause); + } + success = true; + } catch (Exception e) { + success = false; + e.printStackTrace(); + cause = e.getMessage(); + } + if(success){ + StrutsResponseUtils.output(success); + }else{ + JSONObject obj = new JSONObject(); + obj.put("success", false); + obj.put("cause", cause); + StrutsResponseUtils.output(obj); + } + } } Index: forgon-core/src/main/java/com/forgon/systemsetting/action/HttpOptionAction.java =================================================================== diff -u -r34419 -r38291 --- forgon-core/src/main/java/com/forgon/systemsetting/action/HttpOptionAction.java (.../HttpOptionAction.java) (revision 34419) +++ forgon-core/src/main/java/com/forgon/systemsetting/action/HttpOptionAction.java (.../HttpOptionAction.java) (revision 38291) @@ -198,5 +198,58 @@ } StrutsResponseUtils.output(result); } + public void sortHttpOption(){ + JSONObject result = JSONUtil.buildJsonObject(true); + String orderType = StrutsParamUtils.getPraramValue("orderType", null); + try { + Long id = StrutsParamUtils.getPraramLongValue("id", null); + if(DatabaseUtil.isPoIdValid(id)){ + httpOption = httpOptionManager.get(id); + httpOptionManager.sortHttpOption(httpOption, orderType); + } + } catch (Exception e) { + result = JSONUtil.buildJsonObject(false, "操作失败:" + e.getMessage()); + } + StrutsResponseUtils.output(result); + } + public void saveOrUpdateHttpOption(){ + String type = "保存"; + boolean flag = false; + String msg = null; + try { + String optionListId = StrutsParamUtils.getPraramValue("optionListId", null); + String optionText = StrutsParamUtils.getPraramValue("optionText", null); + String optionValue = StrutsParamUtils.getPraramValue("optionValue", null); + Long id = StrutsParamUtils.getPraramLongValue("id", null); + if(DatabaseUtil.isPoIdValid(id)){ + type = "修改"; + }else{ + type = "保存"; + } + httpOptionManager.saveOrUpdateHttpOption(id, optionText, optionListId, optionValue); + flag = true; + } catch (Exception e) { + msg = e.getMessage(); + e.printStackTrace(); + flag = false; + } + JSONObject result = null; + if(flag){ + result = JSONUtil.buildJsonObject(true, type + "成功"); + }else{ + result = JSONUtil.buildJsonObject(false, type+ "失败:" + msg); + } + StrutsResponseUtils.output(result); + } + public void deleteHttpOption(){ + JSONObject result = JSONUtil.buildJsonObject(true, "删除成功"); + String ids = StrutsParamUtils.getPraramValue("ids", null); + try { + httpOptionManager.deleteHttpOption(ids); + } catch (Exception e) { + result = JSONUtil.buildJsonObject(false, "删除失败:" + e.getMessage()); + } + StrutsResponseUtils.output(result); + } } Index: forgon-core/src/main/java/com/forgon/systemsetting/service/HttpOptionManager.java =================================================================== diff -u -r35751 -r38291 --- forgon-core/src/main/java/com/forgon/systemsetting/service/HttpOptionManager.java (.../HttpOptionManager.java) (revision 35751) +++ forgon-core/src/main/java/com/forgon/systemsetting/service/HttpOptionManager.java (.../HttpOptionManager.java) (revision 38291) @@ -131,5 +131,22 @@ * @param ids */ public void deleteWashMethodHttpHttpOption(String ids); - + /** + * 保存或修改httpOption + * @param id + * @param optionText 显示值 + * @param optionListId + * @param optionValue 隐藏值 + */ + public void saveOrUpdateHttpOption(Long id, String optionText, String optionListId, String optionValue); + /** + * 保存或修改httpOption + * @param httpOption + */ + public void saveOrUpdateHttpOption(HttpOption httpOption); + /** + * 删除HttpOption + * @param ids ;分隔 + */ + public void deleteHttpOption(String ids); } Index: ssts-packing/src/main/java/com/forgon/disinfectsystem/packing/service/PackingManagerImpl.java =================================================================== diff -u -r38281 -r38291 --- ssts-packing/src/main/java/com/forgon/disinfectsystem/packing/service/PackingManagerImpl.java (.../PackingManagerImpl.java) (revision 38281) +++ ssts-packing/src/main/java/com/forgon/disinfectsystem/packing/service/PackingManagerImpl.java (.../PackingManagerImpl.java) (revision 38291) @@ -11259,4 +11259,249 @@ } return packingTaskMap; } + @Override + public void deletePackingTask(String deleteCause, String idStr, + Long tousseID, boolean notLossReport, Integer amount) { + if (StringUtils.isNotBlank(idStr)) { + if(StringUtils.isBlank(deleteCause)){ + deleteCause = PackingTask.DELETE_CAUSE_MANUAL; + } + Set ids = SqlUtils.splitLongToSet(idStr, ";", false);//排除传了一样的id 如2;2 + if(ids.size() == 0){ + return; + } + if(ids.size() > 1){//批量删除 + for (Long id : ids) { + PackingTask packingTask = get(id); + delete(packingTask,deleteCause); + } + }else if(ids.size() == 1){ + amount = 1; + Long packingTaskid = null; + for (Long idItem : ids) { + packingTaskid = idItem; + break; + } + PackingTask packingTask = get(packingTaskid); + deletePackingTask(packingTask, amount, notLossReport, deleteCause, tousseID); + } + } + } + /** + * 删除的装配任务数量 + * @param packingTask + * @param amount 删除的装配任务数量 + * @param notLossReport true:不是丢失报损行 false:丢失报损行(因为页面上对于一个有丢失报损的装配任务是显示两行的 此参数主要是区分用户删的是其中的哪一行) + * @param deleteCause 删除原因 + * @param tousseID 装配任务的包定义id + */ + private void deletePackingTask(PackingTask packingTask, Integer amount, boolean notLossReport, String deleteCause, Long tousseID){ + Integer unPackAmount = amount == null?packingTask.getUnPackAmount():packingTask.getUnPackAmount() - amount; + if(!notLossReport){//丢失报损行... + String whereSql = String.format(" where po.packingTaskId=%s and tousseDefinitionId=%s ", packingTask.getId(),tousseID); + @SuppressWarnings("unchecked") + List medds = objectDao.findBySql(MaterialErrorDamageDetail.class.getSimpleName(), + whereSql); + if(CollectionUtils.isNotEmpty(medds)){ + TousseDefinition td = tousseDefinitionManager.get(tousseID); + String tousseName = ""; + if(td != null){ + tousseName = td.getName(); + } + for (MaterialErrorDamageDetail medd : medds) { + medd.setStatus(MaterialErrorDamageDetail.STATUS_ONE);//从装配任务处删除 + objectDao.update(medd); + String msgType = null; + if(MaterialErrorDamageDetail.TYPE_ERROR.equals(medd.getType())){ + msgType = "丢失"; + }else if(MaterialErrorDamageDetail.TYPE_DAMAGE.equals(medd.getType())){ + msgType = "报损"; + }else{ + msgType = "未知的丢失或报损"; + } + String message = String.format("删除了有器械%s的待装配任务,装配任务id:%s,物品名称:%s,包定义id:%s,数量:%s,%s的器械:%s,器械材料定义id:%s,数量:%s", + msgType,packingTask.getId(),tousseName,tousseID,medd.getAmount(),msgType,medd.getMaterialName(),medd.getMaterialDefinitionId(),medd.getAmount()*medd.getAmountPerTousse()); + appLogManager.saveLog(AcegiHelper.getLoginUser(), Log.MODEL_PACKING, + Log.TYPE_DELETE, message); + } + } + } + if(unPackAmount <= 0){ + delete(packingTask,deleteCause); + }else{ + packingTask.setUnPackAmount(unPackAmount); + objectDao.update(packingTask); + } + } + @Override + public void deletePackingTasks(JSONArray deleteInfo, String deleteCause) { + if(CollectionUtils.isEmpty(deleteInfo)){ + return; + } + boolean enableReduceSendAmountAfterTerminatePackAmountFunction = CssdUtils.getSystemSetConfigByNameBool("enableReduceSendAmountAfterTerminatePackAmountFunction", false); + JSONArray terminationNumberOfTousseItemArr = new JSONArray(); //申请物品的终止数量数组 + List ips = new ArrayList(); + for (int i = 0; i < deleteInfo.size(); i++) { + JSONObject delPackingTask = deleteInfo.getJSONObject(i); + Long ptId = delPackingTask.optLong("packingTaskId"); + boolean notLossReport = delPackingTask.optBoolean("notLossReport"); + Integer amount = delPackingTask.optInt("amount", 0); + if(amount < 1){ + continue; + } + PackingTask packingTask = getForUpdate(ptId); + TousseDefinition td = packingTask.getTousseDefinition(); + Long tousseID = td.getId(); + if(packingTask.getUnPackAmount() < amount){ + throw new RuntimeException(packingTask.getDepartment()+"待装配的"+ td.getName() +"待装配数量不足,无法进行终止。"); + } + if(enableReduceSendAmountAfterTerminatePackAmountFunction){ + Long invoicePlanId = getInvoicePlanIdOfPackingTask(packingTask); + if(DatabaseUtil.isPoIdValid(invoicePlanId)){ + InvoicePlan ip = (InvoicePlan)objectDao.getByID_ForUpdate(InvoicePlan.class.getSimpleName(), invoicePlanId); + ips.add(ip); + setTerminationNumberOfTousseItemArr(invoicePlanId, td, amount, terminationNumberOfTousseItemArr); + } + } + deletePackingTask(packingTask, amount, notLossReport, deleteCause, tousseID); + } + if(enableReduceSendAmountAfterTerminatePackAmountFunction && CollectionUtils.isNotEmpty(terminationNumberOfTousseItemArr)){ + batchUpdateTerminatePackingTaskAmount(terminationNumberOfTousseItemArr); + batchSaveDeleteLog(terminationNumberOfTousseItemArr); + //对应的申请单中需要增加相应的备注 + batchUpdateInvoicePlanRemark(terminationNumberOfTousseItemArr, deleteCause); + } + } + /** + * 获取装配任务的申请单id + * @param packingTask 装配任务 + * @return + */ + private Long getInvoicePlanIdOfPackingTask(PackingTask packingTask){ + Long invoicePlanId = null; + if(PackingTask.TASK_APPLICATION.equals(packingTask.getTaskType())){ + invoicePlanId = packingTask.getSourceId(); + }else if(PackingTask.TASK_RECYCLINGRECORD.equals(packingTask.getTaskType())){ + invoicePlanId = objectDao.getALongNum("select max(recyclingapplication_id) id from " + + RecyclingRecord.class.getSimpleName() + + " where id="+packingTask.getSourceId(), "id"); + }else if(PackingTask.TASK_RETURNGOODS.equals(packingTask.getTaskType()) + || PackingTask.TASK_QUALITY_MONITOR.equals(packingTask.getTaskType())){ + invoicePlanId = packingTask.getRpInvoicePlanId(); + } + return invoicePlanId; + } + /** + * 增加日志 + * @param terminationNumberOfTousseItemArr 申请物品的终止数量数组 + */ + private void batchSaveDeleteLog(JSONArray terminationNumberOfTousseItemArr){ + List logMsgs = new ArrayList(); + for (int i = 0; i < terminationNumberOfTousseItemArr.size(); i++) { + JSONObject item = terminationNumberOfTousseItemArr.getJSONObject(i); + int amount = item.optInt("amount"); + String log = "申请单“" + + item.optString("serialNumber") + +"”中的申请物品“" + + item.optString("tousseName") + +"”因待装配数量被终止"+ amount +"个,发货数量同步减少"+ amount +"个"; + logMsgs.add(log); + } + appLogManager.batchSaveLog(AcegiHelper.getLoginUser(), Log.MODEL_INVOICE, Log.TYPE_UPDATE, logMsgs); + + } + /** + * 批量修改申请单备注 + * @param terminationNumberOfTousseItemArr 申请物品的终止数量数组 + * @param deleteCause 终止原因 + */ + private void batchUpdateInvoicePlanRemark(JSONArray terminationNumberOfTousseItemArr, String deleteCause){ + + Map invoicePlanRemarkMap = new HashMap(); + for (int i = 0; i < terminationNumberOfTousseItemArr.size(); i++) { + JSONObject item = terminationNumberOfTousseItemArr.getJSONObject(i); + Long ipId = item.optLong("invoicePlanId"); + String tousseName = item.optString("tousseName"); + int amount = item.optInt("amount"); + String remark = invoicePlanRemarkMap.containsKey(ipId)?invoicePlanRemarkMap.get(ipId):""; + remark += "物品“"+ tousseName +"”待装配数量被终止"+ amount +"个,原因为"+ deleteCause +"。"; + invoicePlanRemarkMap.put(ipId, remark); + } + JSONArray invoicePlanInfos = new JSONArray(); + for (Entry entry : invoicePlanRemarkMap.entrySet()) { + JSONObject obj = new JSONObject(); + obj.put("remark", entry.getValue()); + obj.put("invoicePlanId", entry.getKey()); + invoicePlanInfos.add(obj); + } + String sql = "update " + + InvoicePlan.class.getSimpleName() + +" set remark = case when remark is null then ? else remark" + + dbConnection.getConnector() + +" ? end where id=?"; + jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() { + + @Override + public void setValues(PreparedStatement ps, int i) throws SQLException { + JSONObject item = invoicePlanInfos.getJSONObject(i); + String remark = item.optString("remark"); + ps.setString(1, remark); + ps.setString(2, remark); + ps.setLong(3, item.optLong("invoicePlanId")); + } + + @Override + public int getBatchSize() { + return invoicePlanInfos.size(); + } + }); + + + } + /** + * 批量修改TousseItem.terminatePackingTaskAmount + * @param terminationNumberOfTousseItemArr 申请物品的终止数量数组 + */ + private void batchUpdateTerminatePackingTaskAmount(JSONArray terminationNumberOfTousseItemArr){ + String sql = "update " + TousseItem.class.getSimpleName()+" set terminatePackingTaskAmount = case when terminatePackingTaskAmount is null then ? else terminatePackingTaskAmount+? end where tousseDefinitionId=? and recyclingApplication_ID=? "; + jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() { + + @Override + public void setValues(PreparedStatement ps, int i) throws SQLException { + JSONObject item = terminationNumberOfTousseItemArr.getJSONObject(i); + int amount = item.optInt("amount"); + ps.setInt(1, amount); + ps.setLong(2, amount); + ps.setLong(3, item.optLong("tousseID")); + ps.setLong(4, item.optLong("invoicePlanId")); + } + + @Override + public int getBatchSize() { + return terminationNumberOfTousseItemArr.size(); + } + }); + + + } + /** + * 设置申请物品的终止数量数组 + * @param invoicePlanId 申请单id + * @param td 包定义 + * @param amount 终止数量 + * @param terminationNumberOfTousseItemArr 申请物品的终止数量数组 + */ + private void setTerminationNumberOfTousseItemArr(Long invoicePlanId,TousseDefinition td, Integer amount, JSONArray terminationNumberOfTousseItemArr){ + JSONObject obj = new JSONObject(); + obj.put("invoicePlanId", invoicePlanId); + obj.put("tousseID", td.getId()); + obj.put("amount", amount); + obj.put("tousseName", td.getName()); + obj.put("serialNumber", objectDao.getAStringValue("select serialNumber from " + + InvoicePlan.class.getSimpleName() + + " where id = " + + invoicePlanId + , StringTools.EMPTY)); + terminationNumberOfTousseItemArr.add(obj); + } }