Index: forgon-core/src/main/java/com/forgon/directory/service/OrgUnitManager.java =================================================================== diff -u -r12932 -r12997 --- forgon-core/src/main/java/com/forgon/directory/service/OrgUnitManager.java (.../OrgUnitManager.java) (revision 12932) +++ forgon-core/src/main/java/com/forgon/directory/service/OrgUnitManager.java (.../OrgUnitManager.java) (revision 12997) @@ -121,4 +121,7 @@ */ public CssdServiceDepts getCssdServiceDepts(String applyDepartCode, String type); + + public void updateOldData(String orgCoding,String oldOrgName,String newOrgName); + } Index: forgon-core/src/main/java/com/forgon/directory/service/OrgUnitManagerImpl.java =================================================================== diff -u -r12932 -r12997 --- forgon-core/src/main/java/com/forgon/directory/service/OrgUnitManagerImpl.java (.../OrgUnitManagerImpl.java) (revision 12932) +++ forgon-core/src/main/java/com/forgon/directory/service/OrgUnitManagerImpl.java (.../OrgUnitManagerImpl.java) (revision 12997) @@ -15,7 +15,6 @@ import org.apache.commons.lang.StringUtils; import com.forgon.directory.acegi.tools.AcegiHelper; -import com.forgon.directory.action.OrgUnitAction; import com.forgon.directory.model.CssdHandleTousses; import com.forgon.directory.model.CssdServiceDepts; import com.forgon.directory.model.OrgUnit; @@ -44,7 +43,7 @@ public static transient final String NodePath_ID_OR_Name_Separator = "%&*"; private ObjectDao objectDao; - + public void setThTreeNodeManager(THTreeNodeManager thTreeNodeManager) { this.thTreeNodeManager = thTreeNodeManager; } @@ -321,6 +320,47 @@ thTreeNodeManager.updateTHTreeNode(orgUnit); } } + + /** + * 更新各个模块旧数据 + * @param orgCoding + */ + public void updateOldData(String orgCoding,String oldOrgName,String newOrgName){ + String sql1 = "update invoicePlan set depart = '" + newOrgName + "' where departCoding = '" + orgCoding + "'"; + String sql2 = "update invoicePlan set settleAccountsDepart = '" + newOrgName + "' where settleAccountsDepartCoding = '" + orgCoding + "'"; + String sql3 = "update invoicePlan set handleDepart = '" + newOrgName + "' where handleDepartCoding = '" + orgCoding + "'"; + String sql4 = "update RecyclingRecord set depart = '" + newOrgName + "' where departCode = '" + orgCoding + "'"; + String sql5 = "update invoice set depart = '" + newOrgName + "' where depart = '" + oldOrgName + "'"; + String sql6 = "update invoice set settleAccountsDepart = '" + newOrgName + "' where settleAccountsDepart = '" + oldOrgName + "'"; + String sql7 = "update useRecord set depart = '" + newOrgName + "' where departCoding = '" + orgCoding + "'"; + String sql8 = "update TousseDefinition set handlerDepartName = '"+newOrgName+"' where handlerDepartCode = '" + orgCoding + "'"; + String sql9 = "update TousseInstance set orgUnitName = '" + newOrgName + "' where orgUnitCoding = '" + orgCoding + "'"; + String sql10 = "update TousseInstance set locationForDisplay = '" + newOrgName + "' where location = '" + orgCoding + "'"; + String sql11 = "update SupplyRoomConfig set orgUnitName = '" + newOrgName + "' where orgUnitCoding = '" + orgCoding + "'"; + String sql12 = "update SupplyRoomConfig set dptNameOfForeignTousse = '" + newOrgName + "' where dptCodeOfForeignTousse = '" + orgCoding + "'"; + String sql13 = "update ReturnGoodsRecord set depart = '" + newOrgName + "' where departCoding = '" + orgCoding + "'"; + String sql14 = "update RecallRecordItem set departName = '" + newOrgName + "' where departCode = '" + orgCoding + "'"; + String sql15 = "update RecyclingError set depart = '" + newOrgName + "' where departCode = '" + orgCoding + "'"; + String sql16 = "update RecyclingDamageRecord set depart = '" + newOrgName + "' where departCoding = '" + orgCoding + "'"; + String sql17 = "update QualityMonitoring set orgUnitName = '" + newOrgName + "' where orgUnitCoding = '" + orgCoding + "'"; + objectDao.excuteSQL(sql1); + objectDao.excuteSQL(sql2); + objectDao.excuteSQL(sql3); + objectDao.excuteSQL(sql4); + objectDao.excuteSQL(sql5); + objectDao.excuteSQL(sql6); + objectDao.excuteSQL(sql7); + objectDao.excuteSQL(sql8); + objectDao.excuteSQL(sql9); + objectDao.excuteSQL(sql10); + objectDao.excuteSQL(sql11); + objectDao.excuteSQL(sql12); + objectDao.excuteSQL(sql13); + objectDao.excuteSQL(sql14); + objectDao.excuteSQL(sql15); + objectDao.excuteSQL(sql16); + objectDao.excuteSQL(sql17); + } // 设置部门管理者 private void setManagerRelations(OrgUnit orgUnit) { Index: forgon-core/src/main/java/com/forgon/directory/action/OrgUnitAction.java =================================================================== diff -u -r12932 -r12997 --- forgon-core/src/main/java/com/forgon/directory/action/OrgUnitAction.java (.../OrgUnitAction.java) (revision 12932) +++ forgon-core/src/main/java/com/forgon/directory/action/OrgUnitAction.java (.../OrgUnitAction.java) (revision 12997) @@ -18,10 +18,13 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang.StringUtils; +import com.forgon.directory.acegi.tools.AcegiHelper; import com.forgon.directory.model.BarcodeDevice; import com.forgon.directory.model.CssdServiceDepts; import com.forgon.directory.model.OrgUnit; import com.forgon.directory.service.OrgUnitManager; +import com.forgon.log.model.Log; +import com.forgon.log.service.LogManager; import com.forgon.serialnumber.model.SerialNum; import com.forgon.serialnumber.service.SerialNumManager; import com.forgon.tools.StrutsParamUtils; @@ -47,6 +50,15 @@ public ObjectDao objectDao; + private OrgUnit oldOrgUnit; + + private LogManager appLogManager; + + public void setAppLogManager(LogManager appLogManager) { + this.appLogManager = appLogManager; + } + + public void setSerialNumManager(SerialNumManager serialNumManager) { this.serialNumManager = serialNumManager; } @@ -257,7 +269,6 @@ } public String save() { - if(orgUnit != null){ if(orgUnit.getBarcodeDevice() == null || StringUtils.isBlank(orgUnit.getBarcodeDevice().getBarcode())){ BarcodeDevice barcode = new BarcodeDevice(); @@ -267,34 +278,30 @@ orgUnit.setBarcodeDevice(barcode); } orgUnitManager.saveOrUpdata(orgUnit); + thTreeNodeManager.updateTHTreeNode(orgUnit); + //修改科室名称处理 + if(oldOrgUnit != null && !oldOrgUnit.getName().equals(orgUnit.getName())){ + orgUnitManager.updateOldData(orgUnit.getOrgUnitCoding(), oldOrgUnit.getName(), orgUnit.getName()); + appLogManager.saveLog(AcegiHelper.getLoginUser(), Log.MODEL_BASEDATA, "U", + "组织机构[" + oldOrgUnit.getName() + "]修改名称为[" + orgUnit.getName() + "]科室编码为:" + + orgUnit.getOrgUnitCoding()); + } //返回条码、供页面打印 - HttpServletResponse httpServletResponse = StrutsParamUtils - .getResponse(); + HttpServletResponse response = StrutsParamUtils.getResponse(); try { - httpServletResponse.getWriter().print("{success:true,barcode:'"+orgUnit.getBarcode()+"'}"); + response.getWriter().print("{success:true,barcode:'" + orgUnit.getBarcode() + "'}"); } catch (IOException e) { e.printStackTrace(); } } - - /*String barcode = StrutsParamUtils.getPraramValue("barcode", ""); - if(StringUtils.isNotBlank(barcode)){ - BarcodeDevice barcodeDevice = orgUnit.getBarcodeDevice(); - if(barcodeDevice == null){ - barcodeDevice = new BarcodeDevice(); - } - barcodeDevice.setType(StrutsParamUtils.getPraramValue("type", "")); - barcodeDevice.setBarcode(barcode); - orgUnit.setBarcodeDevice(barcodeDevice); - }*/ - return null; } // 相当于springcontroller的formbackingObject方法 public void iniInfo() { String id = StrutsParamUtils.getPraramValue("id", ""); String parentId = StrutsParamUtils.getPraramValue("parentId", ""); + oldOrgUnit = new OrgUnit(); if (StringUtils.isNotBlank(id) && (!id.equals("0"))) { orgUnit = (OrgUnit) thTreeNodeManager.getTHTreeNodeById( OrgUnit.class.getSimpleName(), Long.valueOf(id)); @@ -309,7 +316,7 @@ // orgUnit.setBarcodeDevice(new BarcodeDevice()); } } - + oldOrgUnit.setName(orgUnit.getName()); } /**